klaim: anti false-success + ukur reward dari isi tx (V45): deteksi mendarat = Hyperion executed ATAU last_claim_time maju dari baseline (⊥ heuristik 24 jam) ; reward_from_tx (bpay+vpay → BP) prioritas, selisih saldo fallback ; reward tak terukur → fee pending + notif KLAIM MENDARAT · REWARD TAK TERUKUR ; next_window baca producer di-retry (⊥ clamp prematur) ; image claim rebuild + push

This commit is contained in:
proitlab committed 2026-08-07 16:22:54 +07:00
1 parent a6db3be436
commit cc9df71d9e
5 files changed
+234 -31

No files matched your search

+111 -6
View File
@@ -69,9 +69,13 @@ def main():
_tg_comm = telegram.TELEGRAM_COMMUNITY_CHAT_IDS
_tg_int = telegram.TELEGRAM_INTERNAL_CHAT_IDS
_tg_post = telegram.requests.post
_req_get = dist.requests.get
telegram.TELEGRAM_BOT_TOKEN = ''
telegram.TELEGRAM_COMMUNITY_CHAT_IDS = []
telegram.TELEGRAM_INTERNAL_CHAT_IDS = []
# Default: pengukuran reward via selisih saldo (tx-based diuji terpisah).
_orig_reward_from_tx = claim.reward_from_tx
claim.reward_from_tx = lambda txid: None
try:
# ————— V32: parse_claim_time — format chain —————
check('V32 parse format %f',
@@ -191,21 +195,121 @@ def main():
row = last_claim_row()
check('V34 reward terukur', row[3] == 10.0 and row[2] == 'txL')
# ————— V34: verify None + last_claim_time maju → dianggap mendarat —————
# ————— V34/V45: verify None + last_claim_time benar2 MAJU → mendarat —————
fresh_db('reconcile')
claim.fetch_producer_last_claim = lambda: (
datetime.now() - timedelta(hours=1)
).strftime('%Y-%m-%dT%H:%M:%S')
last_state = {'n': 0}
def advancing_last():
last_state['n'] += 1
if last_state['n'] == 1: # baseline sebelum kirim
return (datetime.now() - timedelta(hours=2)
).strftime('%Y-%m-%dT%H:%M:%S')
return (datetime.now() - timedelta(hours=1)
).strftime('%Y-%m-%dT%H:%M:%S') # maju → mendarat
claim.fetch_producer_last_claim = advancing_last
balances = iter([Decimal('10.0000'), Decimal('12.0000')])
dist.fetch_balance = lambda: next(balances)
claim.build_claim_action = lambda: FakeSigned(
'txN', exc=RuntimeError('timeout'))
dist.verify_txid = lambda txid: None
check('V34 verify None + last maju → claimed',
check('V45 verify None + last MAJU → claimed',
claim._try_claim_once() == 'claimed')
check('V34 reward tetap diukur',
check('V45 reward tetap diukur',
last_claim_row()[3] == 2.0)
# ————— V45: verify None + last TIDAK maju → retry (⊥ false success) —————
fresh_db('stale')
claim.fetch_producer_last_claim = lambda: (
datetime.now() - timedelta(hours=1)
).strftime('%Y-%m-%dT%H:%M:%S')
dist.fetch_balance = lambda: Decimal('100.0000')
claim.build_claim_action = lambda: FakeSigned(
'txS', exc=RuntimeError('timeout'))
dist.verify_txid = lambda txid: None
check('V45 last tak maju → retry (⊥ sukses-0)',
claim._try_claim_once() == 'retry')
db.ensure_claim_schema()
check('V45 ⊥ catat baris utk yg tak mendarat',
db.queryone('SELECT COUNT(*) FROM claim_runs')[0] == 0)
# ————— V45: reward dari isi tx (bpay+vpay) → prioritas —————
fresh_db('txreward')
claim.fetch_producer_last_claim = lambda: (
datetime.now() - timedelta(hours=25)
).strftime('%Y-%m-%dT%H:%M:%S')
dist.fetch_balance = lambda: Decimal('100.0000') # ⊥ dipakai
claim.build_claim_action = lambda: FakeSigned('txR')
dist.verify_txid = lambda txid: True
def fake_hyperion(url, params=None, timeout=None):
return type('R', (), {
'ok': True,
'raise_for_status': lambda self: None,
'json': lambda self: {
'executed': True,
'actions': [
{'act': {'account': 'vexcore', 'name': 'claimrewards',
'data': {'owner': 'databisnisid'}}},
{'act': {'account': 'vex.token', 'name': 'issue',
'data': {'to': 'vexcore',
'quantity': '82744.9200 VEX'}}},
{'act': {'account': 'vex.token', 'name': 'transfer',
'data': {'from': 'vex.bpay', 'to': 'databisnisid',
'quantity': '638.9244 VEX'}}},
{'act': {'account': 'vex.token', 'name': 'transfer',
'data': {'from': 'vex.vpay', 'to': 'databisnisid',
'quantity': '1200.3217 VEX'}}},
{'act': {'account': 'vex.token', 'name': 'transfer',
'data': {'from': 'databisnisid', 'to': 'someone',
'quantity': '5.0000 VEX'}}},
],
},
})()
dist.requests.get = fake_hyperion
claim.reward_from_tx = _orig_reward_from_tx
check('V45 reward_from_tx jumlah bpay+vpay',
claim.reward_from_tx('txR') == Decimal('1839.2461'))
dist.requests.get = fake_hyperion
check('V45 siklus: reward dari tx → claimed',
claim._try_claim_once() == 'claimed')
row = last_claim_row()
check('V45 reward tx 1839.2461 + fee 183.9246 pending',
row[3] == 1839.2461 and row[4] == 183.9246
and row[5] == 'pending' and row[2] == 'txR')
dist.requests.get = _req_get
claim.reward_from_tx = lambda txid: None
# ————— V45: reward tak terukur (tx gagal + delta gagal) → fee pending —————
fresh_db('unmeasured')
claim.fetch_producer_last_claim = lambda: (
datetime.now() - timedelta(hours=25)
).strftime('%Y-%m-%dT%H:%M:%S')
claim.reward_from_tx = lambda txid: None
bal_seq = iter([Decimal('100.0000'), None, None, None]) # before ok, after ⊥
dist.fetch_balance = lambda: next(bal_seq)
claim.build_claim_action = lambda: FakeSigned('txU')
dist.verify_txid = lambda txid: True
notifs = []
_orig_nc = telegram.notify_claim
_orig_ncu = telegram.notify_claim_unmeasured
def capture_ni(label):
notifs.append('unmeasured')
telegram.notify_claim_unmeasured = capture_ni
telegram.notify_claim = lambda r, f, w: notifs.append('claimed')
check('V45 reward tak terukur → claimed (baris dicatat)',
claim._try_claim_once() == 'claimed')
row = last_claim_row()
check('V45 fee pending utk cek manual (⊥ skipped)',
row[4] == 0.0 and row[5] == 'pending')
check('V45 notif cek manual (⊥ sukses-0)',
'unmeasured' in notifs and 'claimed' not in notifs)
telegram.notify_claim = _orig_nc
telegram.notify_claim_unmeasured = _orig_ncu
# ————— V32: klaim ditolak → retry; poll deadline lewat → timeout —————
fresh_db('timeout')
claim.build_claim_action = lambda: FakeSigned(
@@ -255,6 +359,7 @@ def main():
telegram.TELEGRAM_COMMUNITY_CHAT_IDS = _tg_comm
telegram.TELEGRAM_INTERNAL_CHAT_IDS = _tg_int
telegram.requests.post = _tg_post
dist.requests.get = _req_get
print('\nSEMUA UJI PASS')