test(invoice): test MerchantNonce prevents duplicate invoice creation - #520
Merged
misrasamuelisiguzor-oss merged 1 commit intoAug 31, 2026
Conversation
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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_duplicate_nonce_same_merchant_rejectedDuplicateNoncetest_original_invoice_survives_duplicate_attempttest_duplicate_nonce_does_not_increment_invoice_counttest_same_nonce_different_merchants_both_succeedtest_different_nonces_same_merchant_all_succeedtest_zero_nonce_is_exempt_from_deduplication0is the sentinel — dedup skipped entirelytest_nonce_rejected_after_invoice_is_paidChecklist
merchant_nonce_duplicate_test.rsexisted before this PRcargo test -p comebackhere-invoice --test merchant_nonce_duplicate_test— 7/7 passcargo clippy -p comebackhere-invoice -- -D warnings— cleancargo fmt -p comebackhere-invoice -- --check— clean (pre-existing failures inbatch_expire_cap_test.rsandtest_abi_snapshot_matches_contractare unrelated and present onmain) closes Add a test confirming invoice's MerchantNonce idempotency correctly prevents duplicate invoice creation across concurrent-looking calls #475