Skip to content

test(invoice): test MerchantNonce prevents duplicate invoice creation - #520

Merged
misrasamuelisiguzor-oss merged 1 commit into
WHEELBACK:mainfrom
wendyamoni-creator:test/invoice-merchant-nonce-duplicate-prevention
Aug 31, 2026
Merged

test(invoice): test MerchantNonce prevents duplicate invoice creation#520
misrasamuelisiguzor-oss merged 1 commit into
WHEELBACK:mainfrom
wendyamoni-creator:test/invoice-merchant-nonce-duplicate-prevention

Conversation

@wendyamoni-creator

@wendyamoni-creator wendyamoni-creator commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Closes #475

What

Adds contracts/invoice/tests/merchant_nonce_duplicate_test.rs — a dedicated test file for the core MerchantNonce idempotency guarantee.

Why

Issue #14 documented nonce limits after cancellation, a boundary condition that implicitly presumes the fundamental dedup property holds. This adds an explicit test for that foundational property directly, independent of any lifecycle-specific edge case, so failures in basic nonce deduplication surface immediately on their own terms.

Coverage (7 tests)

Test Property
test_duplicate_nonce_same_merchant_rejected Core: same (merchant, nonce) → DuplicateNonce
test_original_invoice_survives_duplicate_attempt First invoice is intact after the rejection
test_duplicate_nonce_does_not_increment_invoice_count Count stays at 1, no phantom invoice created
test_same_nonce_different_merchants_both_succeed Nonce scope is per-merchant, not global
test_different_nonces_same_merchant_all_succeed Only identical pairs are blocked
test_zero_nonce_is_exempt_from_deduplication Nonce 0 is the sentinel — dedup skipped entirely
test_nonce_rejected_after_invoice_is_paid Dedup key outlives invoice lifecycle state

Checklist

Adds contracts/invoice/tests/merchant_nonce_duplicate_test.rs with 7
focused tests documenting the core MerchantNonce idempotency guarantee
(WHEELBACK#475), independent of the cancellation-specific edge case in WHEELBACK#58.

Tests cover:
- Duplicate (merchant, nonce) pair rejected with DuplicateNonce
- Original invoice survives the rejected duplicate attempt
- Invoice count stays at 1 after a rejected duplicate call
- Nonce scope is per-merchant, not global — different merchants can
  reuse the same nonce value independently
- Distinct nonce values from the same merchant all succeed
- Nonce 0 is the sentinel value and is exempt from deduplication
- Nonce record persists after the original invoice is paid

Confirmed not already covered by a dedicated file before adding.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@wendyamoni-creator 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

@misrasamuelisiguzor-oss
misrasamuelisiguzor-oss merged commit 5dd073f 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

Development

Successfully merging this pull request may close these issues.

Add a test confirming invoice's MerchantNonce idempotency correctly prevents duplicate invoice creation across concurrent-looking calls

2 participants