test(escrow): enforce non-zero escrow amount tests (#95)#224
Conversation
|
@Mikkelnice 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! 🚀 |
📝 WalkthroughWalkthroughAdds integration test coverage for escrow deposit amount validation: zero and negative deposits are rejected with ChangesEscrow deposit validation tests
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
contracts/escrow/src/integration_tests.rs (1)
291-325: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting no side effects on rejection.
Issue
#95requires zero/negative amounts to be rejected before any state writes or token transfers occur. These tests only assert the returned error; they don't verify that no escrow was created and the escrow contract's token balance stayed0. Adding those assertions would actually exercise the "before any state writes" requirement rather than just the error code.♻️ Example assertion to add after each rejection
let token_client = soroban_sdk::token::Client::new(&t.env, &t.token_contract_id); assert_eq!(token_client.balance(&t.escrow_contract_id), 0);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contracts/escrow/src/integration_tests.rs` around lines 291 - 325, Add side-effect checks to the rejection tests in test_deposit_zero_amount_rejected and test_deposit_negative_amount_rejected: after calling EscrowContractClient::try_deposit, assert that no escrow state was created and that the escrow contract’s token balance remains 0. Use the existing TestEnv setup and EscrowContractClient flow, and verify the token balance through the token client so these tests cover rejection before any writes or transfers happen.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@contracts/escrow/src/integration_tests.rs`:
- Around line 291-325: Add side-effect checks to the rejection tests in
test_deposit_zero_amount_rejected and test_deposit_negative_amount_rejected:
after calling EscrowContractClient::try_deposit, assert that no escrow state was
created and that the escrow contract’s token balance remains 0. Use the existing
TestEnv setup and EscrowContractClient flow, and verify the token balance
through the token client so these tests cover rejection before any writes or
transfers happen.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fca3aeed-1df7-493d-8b64-bfa179165ffd
📒 Files selected for processing (1)
contracts/escrow/src/integration_tests.rs
|
Fix conflicts |
|
Resolve conflicts |
Summary
Closes #95
The validation guard (
amount <= 0→InvalidAmount) was already implemented indeposit. This PR adds the missing tests required by the acceptance criteria.Changes
contracts/escrow/src/integration_tests.rs: added three teststest_deposit_zero_amount_rejected— zero amount returnsInvalidAmounttest_deposit_negative_amount_rejected— negative amount returnsInvalidAmounttest_deposit_valid_amount_succeeds— positive amount deposits successfullyTesting
All three paths (zero, negative, valid) are covered by the new contract tests.
Summary by CodeRabbit