-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
Description
🎯 Objective
Design and implement a comprehensive suite of unit and integration tests to ensure the reliability, correctness, and security of the NFT-Fungible Batch Distribution Contract, built using OpenZeppelin’s Stellar contracts and designed for Starshop.
🧪 Scope
Test the following modules and behaviors:
nft-fungible-batch-contract/src/
mint.rs // Batch minting functionality
transfer.rs // Token transfer logic
roles.rs // Access control behavior
storage.rs // Ownership and token state
events.rs // Event emission validation
lib.rs // Initialization and entry point✅ Test Categories & Cases
1. Initialization
- ✅ Should allow contract to be initialized only once
- ✅ Should assign
DEFAULT_ADMIN_ROLEcorrectly - ✅ Should prevent double initialization (revert)
- ✅ Event
ContractInitializedmust be emitted once
2. Role Management
- ✅ Only
ADMIN_ROLEcan assignMINTER_ROLE - ✅ Cannot mint without correct role (should revert)
- ✅ Should emit
RoleGrantedandRoleRevokedevents - ✅ Role checking must be accurate for all privileged operations
3. Minting Logic
- ✅ Should allow authorized minters to call
mint_batch(recipient, quantity) - ✅ Revert if
quantity == 0 - ✅ Revert if caller lacks
MINTER_ROLE - ✅ Revert if recipient is invalid (optional)
- ✅ Generate correct number of token entries in storage
- ✅ Emit
NFTMintedfor each token and oneNFTBatchMintedevent
4. Token Transfer
- ✅ Owner can transfer token to another valid address
- ✅ Cannot transfer token if caller is not owner
- ✅ Ownership must update correctly after transfer
- ✅ Emit
Transfer(from, to, token_id)for each successful transfer
5. Storage Integrity
- ✅ Token ownership and balances are updated properly
- ✅ No overwrite of previous tokens
- ✅ No token ID reuse
- ✅ Keys are scoped and isolated (no collisions)
6. Events & Logging
-
✅ Verify all relevant events are emitted:
ContractInitializedNFTMintedNFTBatchMintedTransferRoleGranted,RoleRevoked
-
✅ Event payloads contain expected values
🧰 Tooling & Environment
- Use
soroban-sdktest utilities - Leverage OpenZeppelin's test helpers where available
- Write tests in Rust using
#[test]andtestutils - Use mock addresses for users (
admin,minter,buyer1,buyer2)
📌 Additional Recommendations
- Include negative test cases (unauthorized mint, transfer without ownership, double init)
- Use helper functions to simulate batch minting
- Use assertions to check state changes after every action
- Structure tests into modules by feature (mint, transfer, roles)