Merged
Conversation
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.
Prevent duplicate payments for the same invoice
Closes #89
What changed
lib.rs—record_paymentalready contains an idempotency guard at step 4(
has_paymentcheck →ContractError::PaymentAlreadyRecorded). No logic changeneeded; the guard was verified to fire before any state mutation or event emission.
test.rs— Added three new acceptance-criteria tests under the section// Prevent duplicate payments — acceptance-criteria tests:test_first_payment_succeeds_emits_event_and_increments_countrecord_paymentstores the record, emitsinvoice_payment_recorded, and incrementspayment_countto 1.test_duplicate_payment_fails_no_event_count_unchangedinvoice_idreverts withPaymentAlreadyRecorded, emits no event, and leavespayment_countunchanged.test_cross_asset_duplicate_same_invoice_id_failsinvoice_idwith a different asset (XLM → USDC) also reverts withPaymentAlreadyRecorded—invoice_idis the sole uniqueness key.Acceptance criteria satisfied
invoice_idreliably reverts withContractError::PaymentAlreadyRecordedpayment_recordedevent emitted on failure; success path unchangedinvoice_idis also rejected