Repository navigation
Closed
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignCampaign: Third CampaignbackendBackend relatedBackend relatedenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Problem
The contract test file (contracts/src/test.rs) covers happy-path creation, deposit, and rebalance, but has no tests for:
set_emergency_stop— no test verifies non-admin callers are rejected, and no test verifies the flag actually blocksdepositandexecute_rebalance- Calling
get_portfolio,check_rebalance_needed, orexecute_rebalancewith a non-existent portfolio ID - Creating a portfolio with an empty allocations map (should fail since sum is 0, not 100)
- Depositing to a portfolio the caller does not own
- Rebalancing a portfolio the caller does not own
Proposed Fix
Add the following test cases to contracts/src/test.rs:
Tests for emergency stop
test_set_emergency_stop_unauthorized— non-admin callsset_emergency_stop(true), call is rejectedtest_set_emergency_stop_blocks_deposit— admin enables stop, user tries to deposit, getsError::EmergencyStoptest_set_emergency_stop_blocks_rebalance— admin enables stop,execute_rebalancereturnsError::EmergencyStop
Tests for error paths
test_get_portfolio_not_found— callget_portfoliowith non-existent ID, assert error (depends on Issue bug: PostgreSQL service missing from docker-compose.yml — Docker deployment fails on database connection #1)test_create_portfolio_empty_allocations— pass emptyMap, verifyError::InvalidAllocation
Tests for ownership checks
test_deposit_wrong_portfolio— user A creates portfolio, user B tries to deposit, rejectedtest_execute_rebalance_not_owner— user A creates portfolio, user B tries to rebalance, rejected
Files to modify
contracts/src/test.rs— add new test functions
Acceptance Criteria
-
test_set_emergency_stop_unauthorizedpasses -
test_set_emergency_stop_blocks_depositpasses -
test_set_emergency_stop_blocks_rebalancepasses -
test_get_portfolio_not_foundpasses -
test_create_portfolio_empty_allocationspasses -
test_deposit_wrong_portfoliopasses -
test_execute_rebalance_not_ownerpasses - All existing tests continue to pass
-
cargo testpasses with no failures
Affected Area
Smart Contract (testing only)
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignCampaign: Third CampaignbackendBackend relatedBackend relatedenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Activity
Oshone87 commentedon Aug 22, 2026
please can i work on this ?
grantfox-oss commentedon Aug 22, 2026
🦊 GrantFox — @Oshone87 has been assigned to this issue as part of the Third Campaign campaign!
Next steps:
Closes #65)Good luck! Track your progress on GrantFox.
test: Add missing contract test coverage for emergency stop, error pa…
grantfox-oss commentedon Aug 23, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Third Campaign campaign!
@Oshone87's PR #70 was approved and merged by @Uchechukwu-Ekezie.
🏆 @Oshone87: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (201 total points). Track your full progress on GrantFox.
👏 Great work, @Oshone87! Keep contributing to grantFoxin.