Skip to content

Add differential fuzzing for invoice and operator privilege boundary test - #516

Merged
misrasamuelisiguzor-oss merged 2 commits into
WHEELBACK:mainfrom
amandasmyths:feat/invoice-compliance-tests
Aug 31, 2026
Merged

Add differential fuzzing for invoice and operator privilege boundary test#516
misrasamuelisiguzor-oss merged 2 commits into
WHEELBACK:mainfrom
amandasmyths:feat/invoice-compliance-tests

Conversation

@amandasmyths

Copy link
Copy Markdown
Contributor

Summary

Implements two issues that improve test coverage and catch potential logic bugs through differential testing:

Resolves

Closes #471
Closes #472

Changes

Issue #471 - Differential Fuzzing for Invoice Amount Validation:

  • scripts/reference_amount_validation.py: Minimal Python reference implementation of invoice amount/precision validation rules
  • contracts/invoice/tests/amount_validation_differential_test.rs: Differential fuzzing test that:
    • Generates randomized test inputs
    • Calls Rust implementation via contract creation
    • Calls Python reference implementation
    • Asserts both implementations agree on success/failure
    • Covers canonical cases, boundary cases (around USDC_FACTOR), and off-by-one scenarios
  • contracts/invoice/Cargo.toml: Added serde_json dev dependency for JSON communication with Python script

Issue #472 - Operator Privilege Boundary Test:

  • contracts/compliance/tests/operator_privilege_boundary_test.rs: 6 comprehensive tests that verify:
    • Operator can successfully call address_status (operator-permitted endpoint)
    • Operator is correctly rejected from allow_address, block_address, clear_address (admin-only operations)
    • Admin retains full access to all operations even after operator is assigned
    • Operator privilege distinction is consistently enforced across multiple operations
  • contracts/compliance/src/lib.rs: Added missing DataKey variants (LastBulkAllow, LastBulkBlock) required by bulk operation cooldown tracking

Testing

Both test suites pass:

  • cargo test --package comebackhere-invoice --test amount_validation_differential_test ✓ (3/3 tests pass)
  • cargo test --package comebackhere-compliance --test operator_privilege_boundary_test ✓ (6/6 tests pass)

The differential test validates that Rust and Python implementations produce identical results across 1000+ test vectors covering:

  • All error cases (zero amounts, negative amounts, precision violations, gross < amount)
  • Valid ranges (minimum valid amounts, round multiples of USDC_FACTOR, large values)
  • Boundary conditions (values one below/at/above USDC_FACTOR threshold)

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@amandasmyths Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…rivilege boundary test

Fixes WHEELBACK#471: Add differential fuzzing harness comparing invoice's amount-validation logic against Python reference implementation to catch logic bugs that might be shared between implementation and test when both in the same language.

Fixes WHEELBACK#472: Add test verifying compliance's require_admin_or_operator correctly distinguishes operator from admin privileges, confirming operator can call address_status but is rejected from admin-only operations like allow_address, block_address, and clear_address.

Changes:
- scripts/reference_amount_validation.py: Minimal Python reference implementation of amount/precision validation rules
- contracts/invoice/tests/amount_validation_differential_test.rs: Differential fuzzing test with canonical cases, boundary cases, and off-by-one tests
- contracts/compliance/tests/operator_privilege_boundary_test.rs: Tests verifying operator vs admin privilege separation
- contracts/compliance/src/lib.rs: Add DataKey::LastBulkAllow and LastBulkBlock variants for bulk operation cooldown tracking
- contracts/invoice/Cargo.toml: Add serde_json dev dependency for test infrastructure
@amandasmyths
amandasmyths force-pushed the feat/invoice-compliance-tests branch from e351af7 to 58a81e9 Compare August 29, 2026 13:40
@misrasamuelisiguzor-oss
misrasamuelisiguzor-oss merged commit be55f76 into WHEELBACK:main Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants