Skip to content

test: add adversarial coverage for commit_snapshot in src/lib.rs - #1303

Closed
blesswill88 wants to merge 3 commits into
RevoraOrg:masterfrom
blesswill88:fix/issue-1137-add-adversarial-coverage-for-commit-snapshot-in
Closed

blesswill88 wants to merge 3 commits into
RevoraOrg:masterfrom
blesswill88:fix/issue-1137-add-adversarial-coverage-for-commit-snapshot-in

Conversation

@blesswill88

Copy link
Copy Markdown

Overview

This PR adds focused adversarial test coverage for the public commit_snapshot method exposed in src/lib.rs. The new tests exercise valid calls, boundary values for each parameter (env: Env, issuer: Address, namespace: Symbol, token: Address, snapshot_ref: u64, content_hash: BytesN<32>), unauthorized callers, and verify that state is unchanged after rejected operations.

Related Issue

Changes

🧪 Snapshot Finalization Tests

  • [ADD] src/test_snapshot_finalization.rs
    • Focused test module covering commit_snapshot success and failure paths.
    • Valid-call coverage: commits a snapshot with well-formed issuer, namespace, token, snapshot_ref, and content_hash, then asserts the resulting state is observable.
    • Boundary coverage for snapshot_ref: u64 (e.g. zero and large values) and content_hash: BytesN<32> (all-zero and all-0xFF hashes).
    • Unauthorized-caller coverage: invokes commit_snapshot from an address that is not the expected issuer and asserts the call is rejected.
    • State-invariance checks: re-reads snapshot state after each rejected operation to confirm nothing was mutated.
    • Deterministic error assertions so failure modes are observable and stable.

Verification Results

cargo test test_snapshot_finalization
✅ focused commit_snapshot tests passed

cargo test
✅ surrounding suite passed

cargo clippy --all-targets -- -D warnings
✅ no warnings

cargo build
✅ build succeeded
Acceptance Criteria Status
Cover the named behavior with focused automated tests, including the relevant success and failure paths ✅ Valid, boundary, and unauthorized paths covered in src/test_snapshot_finalization.rs
Preserve the existing public contract unless the change includes an explicit compatibility plan ✅ No changes to commit_snapshot signature or behavior; tests only
Make error and boundary behavior observable and deterministic ✅ Explicit error assertions and boundary-value cases for snapshot_ref and content_hash

Closes #1137

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.

Add adversarial coverage for commit_snapshot in lib

3 participants