Description
Build an exhaustive, adversarial test suite in contract/src/test.rs for group creation and the query functions (create, get, get_groups_by_creator). Go beyond happy-path — cover boundaries, scale, persistence, and event correctness.
Notes:
- IDs are
BytesN<32> (BytesN::from_array); usage_count is u32; use setup_env().
- Duplicate creation panics ("group already exists"); missing group panics ("group not found").
Tests (required, contract/src/test.rs)
Core
Creator isolation & scale
Boundaries
Persistence & auth
Events
Acceptance Criteria
Dependencies
- ✅
create, get, get_groups_by_creator already implemented
Relevant files
contract/src/test.rs (modified)
Description
Build an exhaustive, adversarial test suite in
contract/src/test.rsfor group creation and the query functions (create,get,get_groups_by_creator). Go beyond happy-path — cover boundaries, scale, persistence, and event correctness.Notes:
BytesN<32>(BytesN::from_array);usage_countisu32; usesetup_env().Tests (required,
contract/src/test.rs)Core
AutoShareDetails(id, name, creator, usage_count, payment_token, empty members)getgeton non-existent group → panic ("group not found")Creator isolation & scale
get_groups_by_creatorreturns all groups for one creator, in insertion orderVecfor a creator with no groupsname/payment_tokenreused across different IDs by the same creator — all coexistBoundaries
usage_count = 0andusage_count = u32::MAXaccepted and stored exactlyPersistence & auth
getin a later call, sameenv)createrequires creator auth — assert failure when the creator hasn't authorized (test without blanketmock_all_auths, usingmock_auths/require_authscoping)Events
createdevent emitted with exact(id, creator)topics/dataAcceptance Criteria
assert!(true)placeholders)make test), builds to WASM (make build), no clippy warnings (make clippy), formatted (make fmt-check)Dependencies
create,get,get_groups_by_creatoralready implementedRelevant files
contract/src/test.rs(modified)