You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add integration tests for buy and sell revert paths covering insufficient funds and oversell #571
The two most critical failure paths in the trading contract — buying with insufficient XLM and selling more keys than a holder owns — both lack integration test coverage. Addressing them in a single issue ensures the revert path test pattern is consistent across buy and sell.
Scope
Insufficient buy: invoke buy with attached amount 1 stroop below the current price; assert revert with the insufficient-funds error code; assert key supply and buyer holdings unchanged
Oversell: set up a holder with exactly 2 keys via buy transactions; invoke sell with quantity 3; assert revert with the insufficient-balance error code; assert holder still owns 2 keys and creator supply unchanged
Both test cases should use a shared setup helper that deploys the contract and seeds a creator
Acceptance Criteria
Buy reverts with insufficient-funds error code when amount is 1 stroop short
Supply and buyer holdings unchanged after failed buy
Sell reverts with insufficient-balance error code when quantity exceeds holdings
Holder balance and creator supply unchanged after failed sell
I'd like to take this one. I write Soroban contract tests in Rust regularly, and revert-path coverage is exactly the kind of testing I prioritize, since the failure paths are where funds actually get protected. The two cases are clear: for the insufficient buy I'd read the current price from the contract and attach exactly price minus 1 stroop so the test stays correct even if the bonding curve or pricing changes, assert the typed insufficient-funds error (matching on the error code, not just any panic), then assert supply and buyer holdings are untouched; for the oversell, seed a holder with exactly 2 keys through real buy calls rather than storage injection so the setup goes through the same path production does, sell 3, assert the insufficient-balance error code, and confirm the holder still has 2 and creator supply is unchanged. Both sit on a shared setup helper that deploys the contract, registers a creator, and funds the test accounts, so future revert tests reuse the same scaffold and the pattern stays consistent as the issue asks. The post-revert state assertions matter as much as the error codes here, since a revert that still mutated state would be the worse bug, and that's exactly what these tests would catch. The 12-hour ETA is comfortable, I'll coordinate in the Telegram as well. Please assign it to me and I'll get started.
Activity
Silver36-ship-it commentedon Jul 23, 2026
I would love to work on this professionally, please assign it to me
ogazboiz commentedon Jul 23, 2026
I'd like to take this one. I write Soroban contract tests in Rust regularly, and revert-path coverage is exactly the kind of testing I prioritize, since the failure paths are where funds actually get protected. The two cases are clear: for the insufficient buy I'd read the current price from the contract and attach exactly price minus 1 stroop so the test stays correct even if the bonding curve or pricing changes, assert the typed insufficient-funds error (matching on the error code, not just any panic), then assert supply and buyer holdings are untouched; for the oversell, seed a holder with exactly 2 keys through real buy calls rather than storage injection so the setup goes through the same path production does, sell 3, assert the insufficient-balance error code, and confirm the holder still has 2 and creator supply is unchanged. Both sit on a shared setup helper that deploys the contract, registers a creator, and funds the test accounts, so future revert tests reuse the same scaffold and the pattern stays consistent as the issue asks. The post-revert state assertions matter as much as the error codes here, since a revert that still mutated state would be the worse bug, and that's exactly what these tests would catch. The 12-hour ETA is comfortable, I'll coordinate in the Telegram as well. Please assign it to me and I'll get started.
grantfox-oss commentedon Jul 23, 2026
🦊 GrantFox — @ogazboiz has been assigned to this issue as part of the Official Campaign | FWC26 campaign!
Next steps:
Closes #571)Good luck! Track your progress on GrantFox.
grantfox-oss commentedon Jul 29, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@ogazboiz's PR #608 was approved and merged by @Chucks1093.
🏆 @ogazboiz: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (519 total points). Track your full progress on GrantFox.
👏 Great work, @ogazboiz! Keep contributing to accesslayerorg.
test: add buy and sell revert path integration tests