fix: resolve #1270, #1269, #1378, #1377 with comprehensive contract t… - #1391
Merged
Merged
Conversation
…eb3Novalabs#1377 with comprehensive contract tests and balance getter Closes Web3Novalabs#1270, Closes Web3Novalabs#1269, Closes Web3Novalabs#1378, Closes Web3Novalabs#1377 Detailed explanation of changes and implementation: 1. Issue Web3Novalabs#1270: Add tests for campaign contribution getter validation - Implemented test_issue_1270_campaign_contribution.rs covering all required edge cases for get_contribution: * (1) Contributor with no donations returns 0 stroops. * (2) Contributor with multiple donations returns the exact arithmetic sum. * (3) Nonexistent contributor who never interacted with the contract returns 0. * (4) Nonexistent campaign correctly panics and returns ContractError::PoolNotFound (Error #1). * (5) Multiple independent contributors are tracked separately without state cross-contamination. 2. Issue Web3Novalabs#1269: Add tests for campaign balance getter edge cases - Added get_campaign_balance function to Contract in lib.rs aliasing get_total_raised to expose standard campaign balance semantics. - Updated and enabled test_campaign_balance.rs covering: * (1) Freshly created campaign returns 0 balance before donations. * (2) Campaign with donations accumulates and returns the correct total. * (3) Nonexistent campaign ID panics and returns ContractError::PoolNotFound (Error #1). * (4) Campaign balance strictly matches the mathematical sum across arbitrary donation amounts. 3. Issue Web3Novalabs#1378: Add tests for emergency withdrawal request-then-execute ordering - Implemented test_issue_1378_emergency_withdrawal_ordering.rs verifying strict lifecycle sequencing: * (1) Execution fails with "Emergency withdrawal not requested" when invoked without prior request. * (2) Execution fails with "Grace period not elapsed" when called before 24h grace period expires. * (3) Execution succeeds immediately at the exact boundary when the grace period finishes. * (4) Caller authorization enforcement: unauthorized non-admin cannot request emergency withdrawal, and token disbursements route strictly to the authorized requester. * (5) Request state cleanup: persistent storage key is removed upon execution, second execution attempt fails, and new requests can be made cleanly. 4. Issue Web3Novalabs#1377: Add tests for set_pool_deadline and get_pool_deadline updates - Implemented test_issue_1377_pool_deadline.rs validating deadline configuration invariants: * (1) Only the authorized pool sponsor can update the deadline; unauthorized callers are rejected. * (2) get_pool_deadline reflects updated sequence values immediately across multiple updates. * (3) Rejects deadlines in the past or equal to the current ledger sequence with "Deadline must be in the future". * (4) Extending and shortening deadline to valid future sequence numbers both succeed as expected. * (5) Invariant preservation: deadline updates on an already-closed pool preserve the closed state (is_closed remains true, donations remain rejected with PoolIsClosed, closing again returns PoolAlreadyClosed). - Registered all four test modules (test_campaign_balance, test_issue_1270_campaign_contribution, test_issue_1378_emergency_withdrawal_ordering, and test_issue_1377_pool_deadline) in lib.rs.
|
@sonoflawal 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.
…ests and balance getter
Closes #1270, Closes #1269, Closes #1378, Closes #1377
Detailed explanation of changes and implementation:
Implemented test_issue_1377_pool_deadline.rs validating deadline configuration invariants:
Registered all four test modules (test_campaign_balance, test_issue_1270_campaign_contribution, test_issue_1378_emergency_withdrawal_ordering, and test_issue_1377_pool_deadline) in lib.rs.
Summary
Related Issue
Closes #
Layer Touched
This PR modifies exactly one layer (per the single-layer-per-PR convention in AGENTS.md):
nevo_frontend— Next.js frontendnevo_server— NestJS backend APInevo_contract— Soroban smart contract (Rust)Checklist
All PRs
main.envfiles, secrets, or API keys are includednode_modules/,target/,.next/,dist/) are committedFrontend (
nevo_frontend/) — if applicablenpm run buildpasses locally (run fromnevo_frontend/)npx tsc --noEmit)MOCK_constants left inapp/orsrc/store/Backend (
nevo_server/) — if applicablenpm run buildpasses locally (run fromnevo_server/)Contract (
nevo_contract/) — if applicablecargo build --release --target wasm32-unknown-unknownpassescargo test --libpasses — all tests greenTesting Notes