Skip to content

test(pm): consensus_sim zero-sum supply + early-exit deferred-claim coverage (PR #124) - #143

Merged
On1x merged 1 commit into
pmfrom
test/pm-consensus-sim-coverage
Aug 10, 2026
Merged

test(pm): consensus_sim zero-sum supply + early-exit deferred-claim coverage (PR #124)#143
On1x merged 1 commit into
pmfrom
test/pm-consensus-sim-coverage

Conversation

@chiliec

@chiliec chiliec commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #142 (the t15 standalone replay, now merged). Adds two CI-wired consensus_sim cases to tests/consensus_sim/scenarios/test_pm_lifecycle.cpp that exercise the PM money paths through the real evaluators + database + settlement cron — closing the two coverage gaps flagged in the PR #124 round-4 review.

supply_conserved_binary_lifecycle

A full binary-market lifecycle (create → extra LP add → unequal two-sided bets → oracle resolve → parimutuel settle with a 6% fee schedule) that asserts current_supply grows by exactly block inflation (CHAIN_DIGITAL_ASSET_ISSUED_PER_BLOCK × blocks).

This is the PR's core safety claim — prediction markets never mint or burn; current_supply untouched — asserted end-to-end for the first time. The existing 51-case suite checks local balances and the pure compute_settlement result struct, but supply_conserved() in the harness is a stub invoked 0× in the PM scenarios.

early_exit_deferred_claim_paid_from_bucket

The F1/#300 early-exit deferred-claim path had zero integration coverage (grep deferred/early_exit/claim_paid across tests/ = 0). This opens a leveraged position, has a whale bet the same side to push it into profit, closes betting so the settlement force-close records the bettor residual as an outcome-contingent deferred claim (asserts it is deferred, not refunded), then resolves the winning side and asserts the claim pays from the bounded early-exit bucket and every claim row is consumed at settlement.

Verification

Built the full chain + consensus_sim_tests target locally and ran both:

Running 2 test cases...
*** No errors detected

Observed values from the real run:

  • supply case: delta=26000 == expected_inflation=26000 (blocks=26)
  • early-exit case: position closes profitable (cv=1232992 > obligation=1100000), bettor_received=132992 recorded as a deferred claim on side A (n=1 total=132992); trader balance unchanged at close (deferred), then rises by exactly 132992 after settlement (paid from the bucket).

Purely additive (273 lines, no existing code touched). Both cases append to pm_lifecycle_suite and auto-register with Boost — no CMake change; they run under ctest/CI like the other 51 cases.

…ims (PR #124)

Two CI-wired consensus_sim cases in test_pm_lifecycle.cpp, driven through the
REAL evaluators + database + settlement cron (not the standalone replay math):

- supply_conserved_binary_lifecycle: a full binary-market lifecycle (create,
  extra LP add, unequal two-sided bets, oracle resolve, parimutuel settle with
  a 6% fee schedule) and asserts current_supply grows by EXACTLY block inflation
  (CHAIN_DIGITAL_ASSET_ISSUED_PER_BLOCK x blocks). This is the PR's core safety
  claim ("PM never mints or burns; current_supply untouched") — the 51-case
  suite checks local balances and the pure compute_settlement struct, but never
  asserted global chain conservation end-to-end.

- early_exit_deferred_claim_paid_from_bucket: the F1/steemit#300 early-exit deferred-
  claim path had ZERO integration coverage (grep deferred/early_exit/claim_paid
  across tests/ = 0). Opens a leveraged position, a whale bets the same side to
  push it into profit, betting closes so the settlement force-close records the
  bettor residual as an outcome-contingent deferred claim (asserts it is DEFERRED,
  not refunded), then resolves the winning side and asserts the claim pays from
  the bounded early-exit bucket and every claim row is consumed at settlement.

Both verified GREEN against pm head (built the full chain locally): "Running 2
test cases... *** No errors detected".
@On1x
On1x merged commit e0f7040 into pm Aug 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants