test(stablecoin): add the full position lifecycle integration test - #355
Open
gravityblast wants to merge 1 commit into
Open
test(stablecoin): add the full position lifecycle integration test#355gravityblast wants to merge 1 commit into
gravityblast wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new lifecycle test mutates stablecoin total_supply for the seeded buffer but doesn’t assert post-borrow/repay supply and balances stay consistent, leaving a key end-to-end invariant unverified.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new stablecoin end-to-end integration test that exercises the full “Plan 3” position lifecycle through the zkVM on top of a properly bootstrapped protocol state (via initialize_program), including Plan 2 stability-fee accrual between borrow and repay.
Changes:
- Add
stablecoin_full_position_lifecycleintegration test covering open → deposit → borrow → accrue → repay → withdraw → close. - Generalize
assert_fungible_balanceby introducingassert_fungible_balance_ofto assert holdings for non-collateral token definitions (stablecoin holdings).
File summaries
| File | Description |
|---|---|
| programs/integration_tests/tests/stablecoin.rs | Adds the full-lifecycle stablecoin zkVM integration test and a generalized fungible-balance assertion helper. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+984
to
+985
| assert_eq!(read_position(&state).normalized_debt_amount, 0); | ||
|
|
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.
Adds
stablecoin_full_position_lifecycle, the end-to-end test that closes outPlan 3: open → deposit → borrow → accrue → repay → withdraw → close, all through
the zkVM against a really-bootstrapped protocol (
initialize_program, notforce-inserted globals).
This is "Mode A" from the issue — Plan 2 has shipped, so
accrue_stability_feeruns between borrowing and repaying. The test asserts the accumulator moves above
FIXED_POINT_ONEand that the accrued nominal debt exceeds the amount minted,which is the only place §6.3's directional rounding gets exercised at a
non-trivial accumulator.
That fee gap is why the owner is seeded with a stablecoin balance before
borrowing: repaying in full costs more than was minted, so the shortfall has to
come from somewhere — the market, per §2.
total_supplyis credited to match, orthe chained Burn underflows.
Two things the run surfaced, both already handled in the stack:
generate_debt'sstaleness gate correctly rejects against a real wall clock. The test seeds a
fresh observation.
close_positioncannot clear the account toAccount::default(); see feat(stablecoin): add close_position instruction #354.assert_fungible_balancewas hardcoded to the collateral definition, so it grewan
assert_fungible_balance_ofvariant for the stablecoin holding.Last of eight issues in Plan 3 (#173). Stacked on #354.
closes #181