Skip to content

fix: resolve #1270, #1269, #1378, #1377 with comprehensive contract t… - #1391

Merged
cyber-punk112 merged 2 commits into
Web3Novalabs:mainfrom
sonoflawal:main
Sep 24, 2026
Merged

cyber-punk112 merged 2 commits into
Web3Novalabs:mainfrom
sonoflawal:main

Conversation

@sonoflawal

Copy link
Copy Markdown
Contributor

…ests and balance getter

Closes #1270, Closes #1269, Closes #1378, Closes #1377

Detailed explanation of changes and implementation:

  1. Issue Add tests for campaign contribution getter validation #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 Setup GitHub CI/CD Pipeline #1).
    • (5) Multiple independent contributors are tracked separately without state cross-contamination.
  1. Issue Add tests for campaign balance getter edge cases #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 Setup GitHub CI/CD Pipeline #1).
    • (4) Campaign balance strictly matches the mathematical sum across arbitrary donation amounts.
  1. Issue Add tests for emergency withdrawal request-then-execute ordering #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.
  1. Issue Add tests for set_pool_deadline and get_pool_deadline updates #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.

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 frontend
  • nevo_server — NestJS backend API
  • nevo_contract — Soroban smart contract (Rust)
  • Other (docs, CI, repo config — no source layer changed)

If your changes span more than one source layer, stop and split this PR.

Checklist

All PRs

  • The branch is up to date with main
  • No .env files, secrets, or API keys are included
  • No auto-generated files (node_modules/, target/, .next/, dist/) are committed

Frontend (nevo_frontend/) — if applicable

  • npm run build passes locally (run from nevo_frontend/)
  • No TypeScript errors (npx tsc --noEmit)
  • No MOCK_ constants left in app/ or src/store/
  • New or updated tests added where appropriate

Backend (nevo_server/) — if applicable

  • npm run build passes locally (run from nevo_server/)
  • No TypeScript errors
  • New endpoints follow RESTful conventions

Contract (nevo_contract/) — if applicable

  • cargo build --release --target wasm32-unknown-unknown passes
  • cargo test --lib passes — all tests green
  • No unsafe code introduced without justification

Testing Notes

…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.
@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@cyber-punk112
cyber-punk112 merged commit 370a0c4 into Web3Novalabs:main Sep 24, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants