@@ -232,11 +232,11 @@ def test_bootstrap_exactly_at_total_issuance_is_accepted(tmp_path: Path) -> None |
232 | 232 | assert e.balances().issued == 30_000 and e.balances().conserved() |
233 | 233 |
|
234 | 234 |
|
235 | | -def _pending_reservation(e) -> None: |
236 | | - """A reserved, not yet accepted shadow round: it will mint round_reward_units.""" |
| 235 | +def _pending_reservation(e, accepted: str = "null") -> None: |
| 236 | + """A shadow reservation row; `accepted` null = pending, it will mint round_reward_units.""" |
237 | 237 | e.db.execute( |
238 | 238 | "INSERT INTO records_v2 VALUES(?,?,?,?)", |
239 | | - (e.run_id, "shadow-reservation", "0", '{"binding":{},"accepted":null}'), |
| 239 | + (e.run_id, "shadow-reservation", "0", f'{{"binding":{{}},"accepted":{accepted}}}'), |
240 | 240 | ) |
241 | 241 |
|
242 | 242 |
|
@@ -258,3 +258,15 @@ def test_bootstrap_counts_pending_shadow_reservation_against_cap( |
258 | 258 | with pytest.raises(EscrowError, match="TOTAL_ISSUANCE_BUDGET"): |
259 | 259 | e.production_bootstrap(bootstrap(e.run_id)) |
260 | 260 | assert e.balances().issued == 0 |
| 261 | + |
| 262 | + |
| 263 | +def test_bootstrap_ignores_accepted_shadow_reservation(tmp_path: Path) -> None: |
| 264 | + # Given: an accepted reservation. Its units are already in balances().issued, so counting |
| 265 | + # it again as pending would double count and refuse a bootstrap that exactly fits the cap. |
| 266 | + s = pinned(E.setup("production"), max_total_issuance=30_000) |
| 267 | + e = E.ledger(s, tmp_path / "ledger.db") |
| 268 | + _pending_reservation(e, accepted="1") |
| 269 | + # When |
| 270 | + e.production_bootstrap(bootstrap(e.run_id)) |
| 271 | + # Then |
| 272 | + assert e.balances().issued == 30_000 and e.balances().conserved() |