Repository navigation
test: prove double-invocation of collect_fees never double-collects - #178
Open
mordabdul1 wants to merge 1 commit into
Open
mordabdul1 wants to merge 1 commit into
mordabdul1 wants to merge 1 commit into
Conversation
mordabdul1
force-pushed
the
test/collect-fees-double-invocation-80
branch
from
October 23, 2026 12:57
ac7944e to
c9e4070
Compare
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.
Summary
Closes #80.
Adds
test_collect_fees_double_invocation_never_double_collectsto src/test.rs:collect_fees(asset)is invoked twice in immediate succession (same ledger — the env's sequence number is never advanced), asserting the first call pays the full accrual and zeroesfees_accrued, and the second fails withError::NoFeesToCollect— never re-collecting the same amount. The test further proves post-collection accruals form a fresh balance (exactly the new amount is collectable, no residue) and that the guarantee holds again after re-accrual.Checks-effects-interactions review (no gap found)
collect_feesin src/lib.rs already follows CEI ordering, so no reorder was needed:NoFeesToCollect).fees_accruedis zeroed; this is the function's only state mutation.With no external call frame anywhere in the function, there is nothing for a malicious token to reenter through — and the Soroban host additionally forbids contract reentrancy outright, so the guarantee is defense in depth. Should a real token payout ever be added to this path, the accrual is already zeroed before the point where such a transfer would go, and this regression test would pin the observable behavior.
Testing
Full suite: 154 passed, 0 failed.
cargo fmt --checkclean.Incidental
Bumps
ethnum1.5.2 → 1.5.3 inCargo.lock(1.5.2 fails to compile on recent rustc, E0512). Same patch bump as #173/#174/#175/#177; merges cleanly in any order.