T14: penanda vote basi (last_vote dari rasio bobot/stake, filter ?stale=1, VEX_STALE_DAYS)

This commit is contained in:
proitlab committed 2026-08-04 17:05:16 +07:00
1 parent 2b95be3091
commit b0b3ba8ab3
10 files changed
+236 -52

No files matched your search

+20
View File
@@ -7,6 +7,7 @@ Dalam setiap contoh, 'last_vote_weight' berisi 17 desimal (bobot teliti).
import os
import sqlite3
import tempfile
from datetime import datetime
import requests
@@ -98,6 +99,24 @@ def main():
check('staked ÷10000', by['aaa1']['staked'] == 1200.0)
check('staked batas ≥1000 ÷10000', by['ccc3']['staked'] == 1000.0)
# V13: last_vote diturunkan di normalize dari rasio bobot/stake
check('V13 last_vote ikut dinormalisasi', 'last_vote' in by['aaa1'])
check('V13 bobot/stake rasio kecil → sebelum 2000',
by['ccc3']['last_vote'] is not None
and by['ccc3']['last_vote'] < '2000-01-01')
# V13: formula — staked_raw × 2^26 → ~2026-01-01 (±2 hari, toleransi 365.25 hari/tahun)
lv = gv.derive_last_vote(f'{12000000 * 2 ** 26}.00000000000000000', 1200.0)
lv_dt = datetime.fromisoformat(lv) if lv else None
check('V13 formula 2^26 → ~2026-01-01',
lv_dt is not None and abs((lv_dt - datetime(2026, 1, 1)).days) <= 2)
check('V13 rasio 1.0 → epoch 2000',
gv.derive_last_vote('12000000.00000000000000000', 1200.0) == '2000-01-01T00:00:00')
check('V13 bobot nol → None', gv.derive_last_vote('0', 1200.0) is None)
check('V13 bobot kosong → None', gv.derive_last_vote('', 1200.0) is None)
check('V13 bobot tak valid → None', gv.derive_last_vote('abc', 1200.0) is None)
check('V13 stake nol → None', gv.derive_last_vote('1.0', 0.0) is None)
# V9: staked < 1000 VEX → dibuang; tepat 1000 → disimpan
check('V9 di bawah 1000 dibuang',
gv.normalize({'owner': 'low9', 'producers': [gv.TARGET_BP],
@@ -141,6 +160,7 @@ def main():
stamps = set(r[3] for r in rows)
check('V7 semua baris cap waktu scan ini', len(stamps) == 1)
check('V7 owner PRIMARY KEY', 'owner' in cols and pk == ['owner'])
check('V7 kolom last_vote ada', 'last_vote' in cols)
print('\nSEMUA UJI PASS')