Skip to content

test(contract): exhaustive test suite for group creation & retrieval (boundaries, scale, persistence) #64

Description

@Akshola00

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

  • Successful creation — assert every field of AutoShareDetails (id, name, creator, usage_count, payment_token, empty members)
  • Retrieve by ID via get
  • get on non-existent group → panic ("group not found")
  • Duplicate ID creation → panic ("group already exists")

Creator isolation & scale

  • get_groups_by_creator returns all groups for one creator, in insertion order
  • Empty Vec for a creator with no groups
  • Multiple creators fully isolated — no cross-leakage
  • Scale: one creator with many groups (e.g. 50) — all retrievable, order preserved
  • Same name/payment_token reused across different IDs by the same creator — all coexist

Boundaries

  • usage_count = 0 and usage_count = u32::MAX accepted and stored exactly
  • Empty string name and a long name — stored faithfully
  • IDs differing by a single byte are treated as distinct groups

Persistence & auth

  • State persists across separate client calls (create, then get in a later call, same env)
  • create requires creator auth — assert failure when the creator hasn't authorized (test without blanket mock_all_auths, using mock_auths/require_auth scoping)

Events

  • created event emitted with exact (id, creator) topics/data
  • Event count matches number of successful creates (no spurious events on panics)

Acceptance Criteria

  • All categories above covered with precise assertions (no assert!(true) placeholders)
  • Scale and boundary cases included; auth-failure path verified without global auth mocking
  • Event payloads and counts asserted
  • All tests pass (make test), builds to WASM (make build), no clippy warnings (make clippy), formatted (make fmt-check)

Dependencies

  • create, get, get_groups_by_creator already implemented

Relevant files

  • contract/src/test.rs (modified)

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaigncontractSmart Contract (Soroban/Rust)testsTesting and test coverage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions