This guide explains how to verify the Registry Contract implementation meets all requirements from Issue #9.
Ensure Rust and Cargo are installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknownNavigate to the contracts directory and run the test suite:
cd contracts
cargo testExpected output should show all tests passing:
running 19 tests
test test::test_initialize_admin ... ok
test test::test_initialize_admin_twice_fails ... ok
test test::test_update_admin ... ok
test test::test_update_admin_unauthorized_fails ... ok
test test::test_approve_contract ... ok
test test::test_revoke_contract ... ok
test test::test_approve_contract_unauthorized_fails ... ok
test test::test_record_activity_as_admin ... ok
test test::test_record_activity_as_approved_contract ... ok
test test::test_record_multiple_activities ... ok
test test::test_activities_different_campaigns ... ok
test test::test_get_activities_empty_campaign ... ok
test test::test_activity_timestamp_and_ledger ... ok
test test::test_record_activity_as_authorized_user ... ok
test test::test_all_activity_actions ... ok
Verify: Check registry/src/types.rs
grep -A 10 "pub struct ActivityRecord" registry/src/types.rsShould show:
- actor: Address
- action_type: ActivityAction
- timestamp: u64
- ledger_sequence: u32
Verify: Check registry/src/activity.rs
grep -A 5 "pub fn record_activity" registry/src/activity.rsVerify: Run authorization tests
cargo test test_record_activityAll tests should pass, confirming:
- Admin can record activities
- Approved contracts can record activities
- Authorized users can record activities
Verify: Check retrieval function
grep -A 5 "pub fn get_campaign_activities" registry/src/activity.rsRun tests:
cargo test test_get_campaign_activities
cargo test test_activities_different_campaignsVerify: Check event emission
grep "activity_recorded" registry/src/events.rsVerify: Run all activity tests
cargo test test_record_activity
cargo test test_get_activities
cargo test test_all_activity_actionsVerify: Run initialization tests
cargo test test_initialize_admin
cargo test test_initialize_admin_twice_failsShould confirm:
- Admin can be set during initialization
- Re-initialization is prevented
Verify: Run admin update tests
cargo test test_update_admin
cargo test test_update_admin_unauthorized_failsShould confirm:
- Admin can transfer role
- Non-admin cannot update admin
Verify: Check admin module
grep -E "require_admin|get_admin" registry/src/admin.rsVerify: Run contract approval tests
cargo test test_approve_contract
cargo test test_revoke_contract
cargo test test_approve_contract_unauthorized_failsVerify: Check event definitions
grep -E "admin_updated|contract_approved|contract_revoked" registry/src/events.rsVerify: Run all admin tests
cargo test test_initialize
cargo test test_update_admin
cargo test test_approve_contract
cargo test test_revoke_contractBuild the contract to ensure it compiles without errors:
cargo build --target wasm32-unknown-unknown --releaseSuccessful build should produce:
target/wasm32-unknown-unknown/release/registry.wasm
- Activity record creation
- Activity record retrieval
- Authorization checks
- Multiple activities per campaign
- Activities across campaigns
- Empty campaign queries
- Timestamp recording
- Ledger sequence recording
- All action types
- Deterministic ordering
- Admin initialization
- Duplicate initialization prevention
- Admin retrieval
- Admin transfer
- Unauthorized admin operations
- Contract approval
- Contract revocation
- Contract approval checks
- Unauthorized contract operations
While unit tests verify individual functions, integration testing should verify:
- Contract deployment and initialization
- Admin operations in sequence
- Activity recording from multiple actors
- Event emission and indexing
- Storage TTL behavior
These can be tested on testnet once deployment tooling is configured.
Run this command to verify all tests pass:
cargo test 2>&1 | grep -E "test result:|running"Expected output:
running 19 tests
test result: ok. 19 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
All 19 tests passing confirms all acceptance criteria are met.
The implementation uses efficient storage patterns:
- Instance storage for global state (admin, approvals)
- Persistent storage for activity records
- Vector-based activity storage (O(1) append, O(n) retrieval)
- TTL management prevents data expiration
For campaigns with thousands of activities, consider implementing pagination in future versions.
Key security features to verify:
- Admin cannot be overwritten after initialization
- Only admin can approve contracts
- Activity records are append-only
- Authorization is checked before state changes
- Events are emitted for all state changes
- Storage TTL is properly managed
If tests fail:
- Ensure Rust toolchain is up to date:
rustup update - Clean and rebuild:
cargo clean && cargo build - Check for missing dependencies:
cargo check - Verify wasm32 target is installed:
rustup target list --installed
For build errors:
- Check Cargo.toml versions match workspace
- Ensure soroban-sdk version is compatible
- Verify all module declarations in lib.rs
After verification:
- Deploy to Stellar testnet
- Initialize with admin address
- Test with real transactions
- Set up indexing service to consume events
- Integrate with escrow contracts
- Build frontend integration