Skip to content

Feature/test revoke nonexistent validator - #147

Open
johnsaviour56-ship-it wants to merge 5 commits into
scout-off:mainfrom
johnsaviour56-ship-it:feature/test-revoke-nonexistent-validator
Open

Feature/test revoke nonexistent validator#147
johnsaviour56-ship-it wants to merge 5 commits into
scout-off:mainfrom
johnsaviour56-ship-it:feature/test-revoke-nonexistent-validator

Conversation

@johnsaviour56-ship-it

Copy link
Copy Markdown
Contributor

Added unit test coverage for the validator revocation failure path when attempting to revoke a non-existent validator.

Summary

  • Added test_revoke_nonexistent_validator_fails()
  • Uses #[should_panic] to validate expected failure behavior
  • Verifies revoke_validator correctly handles unknown wallet addresses by triggering the ValidatorNotFound path

Testing

  • Confirmed test passes successfully
  • Ensures error handling for invalid revocation requests is explicitly covered
  • Improves regression coverage for validator management edge cases

Notes

  • No functional contract changes introduced
  • Focused solely on strengthening negative-path test coverage

Closes #65

Prevents Admin, Initialized, Paused, and ProgressContract keys from expiring in instance storage.

Changes:
- Add INSTANCE_TTL_MIN (100) and INSTANCE_TTL_MAX (500) constants to all contracts
- Call env.storage().instance().extend_ttl() at the start of every public function
- Add unit tests verifying contracts remain functional after ledger advancement

Contracts updated:
- progress: initialize, pause_contract, unpause_contract, transfer_admin, advance_level
- registration: initialize, pause_contract, unpause_contract, register_player, update_profile, register_scout
- verification: initialize, set_progress_contract, pause_contract, unpause_contract, approve_milestone
- scout_access: initialize, update_fee_config, withdraw_fees, pause_contract, unpause_contract, subscribe, pay_to_contact, log_trial_offer

Acceptance Criteria:
✓ Every public function extends instance TTL
✓ Unit tests verify contract functionality after simulated ledger advancement
Allows admins to update validator credentials on-chain, enabling validators to reflect license upgrades.

Changes:
- Add update_validator_credentials(env, wallet, new_credentials) function (admin only)
- Validate new_credentials length ≤ 256 bytes
- Emit validator_credentials_updated event
- Return ValidatorNotFound if wallet not registered
- Preserve other validator fields (registered_at, active status, wallet)

Tests:
✓ Admin can update credentials
✓ Non-admin call returns Unauthorized
✓ ValidatorNotFound error when wallet not registered
✓ InvalidInput error when credentials exceed 256 bytes
✓ Success with exactly 256 bytes
✓ Other validator fields are preserved after update
✓ Event is emitted on successful update
Adds dedicated test to verify set_progress_contract stores the progress contract address correctly in instance storage.

Changes:
- Add test_set_progress_contract_stores_address() test
- Verifies address is stored in DataKey::ProgressContract
- Asserts stored address equals the one passed to set_progress_contract
- Uses env.as_contract() to access instance storage directly

Acceptance Criteria:
✓ Test exists and passes
✓ Asserts stored address equals input address
Adds test to verify revoke_validator returns ValidatorNotFound error when attempting to revoke a validator that is not registered.

Changes:
- Add test_revoke_nonexistent_validator_fails() test with #[should_panic]
- Verifies error path for unknown wallet addresses
- Ensures ValidatorNotFound error is properly returned

Acceptance Criteria:
✓ Test exists and passes
@drips-wave

drips-wave Bot commented May 28, 2026

Copy link
Copy Markdown

@johnsaviour56-ship-it 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write test for revoke_validator on a non-existent wallet

1 participant