test(pm): consensus_sim zero-sum supply + early-exit deferred-claim coverage (PR #124) - #143
Merged
Merged
Conversation
…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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #142 (the
t15standalone replay, now merged). Adds two CI-wiredconsensus_simcases totests/consensus_sim/scenarios/test_pm_lifecycle.cppthat 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_lifecycleA full binary-market lifecycle (create → extra LP add → unequal two-sided bets → oracle resolve → parimutuel settle with a 6% fee schedule) that asserts
current_supplygrows 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_settlementresult struct, butsupply_conserved()in the harness is a stub invoked 0× in the PM scenarios.early_exit_deferred_claim_paid_from_bucketThe
F1/#300early-exit deferred-claim path had zero integration coverage (grep deferred/early_exit/claim_paidacrosstests/= 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_teststarget locally and ran both:Observed values from the real run:
delta=26000 == expected_inflation=26000 (blocks=26)cv=1232992 > obligation=1100000),bettor_received=132992recorded as a deferred claim on side A (n=1 total=132992); trader balance unchanged at close (deferred), then rises by exactly132992after settlement (paid from the bucket).Purely additive (273 lines, no existing code touched). Both cases append to
pm_lifecycle_suiteand auto-register with Boost — no CMake change; they run underctest/CI like the other 51 cases.