test(contracts): bonding curve regression tests + stroop display helper#358
Open
Dannyswiss1 wants to merge 1 commit into
Open
test(contracts): bonding curve regression tests + stroop display helper#358Dannyswiss1 wants to merge 1 commit into
Dannyswiss1 wants to merge 1 commit into
Conversation
|
@Dannyswiss1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
This PR adds 4 regression tests and a test helper to verify bonding curve math, admin invariants, and improve test readability per audit follow-ups.
What's Changed
Buy Quote Consistency - #352
test_buy_quote_updates_after_sellincontracts/src/test.rsS, performssellto reduce supply toS'bonding_curve_price(S')helperAdmin Address Invariant - #353
test_admin_unchanged_after_fee_updateget_protocol_admin()beforeupdate_fee_config()Stroop Display Helper - #354
test_helpers.rswithto_display_units(stroops: u128) -> Decimalconst STROOP_SCALE: u128 = 10_000_000as named constanttest_large_buy_amountandtest_fee_calculationassert_eq!(amount, 15000000000u128)assert_eq!(to_display_units(amount), dec!(1500.0))Buy/Sell Symmetry - #355
test_buy_sell_symmetric_price_impactNkeys at supplySNkeys, then sellsNkeyssell_proceeds = buy_cost - feeswithin1 strooptolerancesell_quote(buy(S, N)) ≈ buy_cost * (1 - fee_bps/10000)Testing Done
cargo test -p accesslayer-contracts→ 4 new tests pass, 0 regressionscargo fmt --all -- --check→ passcargo clippy --all-targets -- -D warnings→ 0 new warningstest_buy_quote_updates_after_sellfails if quote logic commented outtest_admin_unchanged_after_fee_updatefails if admin overwritten in update pathto_display_units(10_000_000) == dec!(1.0)Notes
All tests use existing
bonding_curve_pricehelper for expected values. No changes to contract logic, tests only.STROOP_SCALEmatches Stellar asset precision.Closes #352
Closes #353
Closes #354
Closes #355