From 65f0a1845e71d13b0fab9ecec57003f90f9f8013 Mon Sep 17 00:00:00 2001 From: echobt <154886644+echobt@users.noreply.github.com> Date: Wed, 21 Oct 2026 21:37:23 +0000 Subject: [PATCH] test(ledger): guard the accepted filter of the bootstrap pending count production_bootstrap counts pending shadow reservations against the issuance cap with `accepted IS NULL`. An accepted reservation is already in balances().issued, so dropping the filter double counts it and refuses a bootstrap that exactly fits the cap. Lens found no test failed when the filter was removed. Add one with an accepted reservation at an exact fit; it fails with the filter removed. Tests only, nothing under src/. Co-Authored-By: Claude Sonnet 5.5 --- tests/ledger/test_production_bootstrap_v2.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/ledger/test_production_bootstrap_v2.py b/tests/ledger/test_production_bootstrap_v2.py index 726cd93..222cc66 100644 --- a/tests/ledger/test_production_bootstrap_v2.py +++ b/tests/ledger/test_production_bootstrap_v2.py @@ -232,11 +232,11 @@ def test_bootstrap_exactly_at_total_issuance_is_accepted(tmp_path: Path) -> None assert e.balances().issued == 30_000 and e.balances().conserved() -def _pending_reservation(e) -> None: - """A reserved, not yet accepted shadow round: it will mint round_reward_units.""" +def _pending_reservation(e, accepted: str = "null") -> None: + """A shadow reservation row; `accepted` null = pending, it will mint round_reward_units.""" e.db.execute( "INSERT INTO records_v2 VALUES(?,?,?,?)", - (e.run_id, "shadow-reservation", "0", '{"binding":{},"accepted":null}'), + (e.run_id, "shadow-reservation", "0", f'{{"binding":{{}},"accepted":{accepted}}}'), ) @@ -258,3 +258,15 @@ def test_bootstrap_counts_pending_shadow_reservation_against_cap( with pytest.raises(EscrowError, match="TOTAL_ISSUANCE_BUDGET"): e.production_bootstrap(bootstrap(e.run_id)) assert e.balances().issued == 0 + + +def test_bootstrap_ignores_accepted_shadow_reservation(tmp_path: Path) -> None: + # Given: an accepted reservation. Its units are already in balances().issued, so counting + # it again as pending would double count and refuse a bootstrap that exactly fits the cap. + s = pinned(E.setup("production"), max_total_issuance=30_000) + e = E.ledger(s, tmp_path / "ledger.db") + _pending_reservation(e, accepted="1") + # When + e.production_bootstrap(bootstrap(e.run_id)) + # Then + assert e.balances().issued == 30_000 and e.balances().conserved()