e2e/qa: fix withdraw accounting invariant for free-seat override#3561
Merged
e2e/qa: fix withdraw accounting invariant for free-seat override#3561
Conversation
The money-conservation invariant was tied to effective_price, which breaks on mainnet where the selected seat has a zero price override: we still pay parsedAmount at FeedSeatPay (debit = epochPrice) and get it all back on withdraw, but effective_price = 0, so refund + retained (30M + 0) != effective_price (0). Switch the invariant to parsedAmount (what we actually paid), and guard the prorating-only partial-refund checks against the zero effective_price case. Also tweak the partial-refund check to assert retained < effective_price (kept less than a full epoch) instead of refund < effective_price, which was the wrong direction.
doublezero-shreds moved go.mod from e2e/ to the repo root (PR #287 / #288 landed the account-side Go SDK and collapsed the e2e subdir module into the main module). The shreds-e2e workflow still referenced e2e/go.mod for setup-go, failing with "specified go version file at: e2e/go.mod does not exist". Update both go-version-file references. Working directory and ./cmd/devnet paths are unchanged since test files stay under e2e/.
snormore
approved these changes
Apr 21, 2026
martinsander00
approved these changes
Apr 21, 2026
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
TestQA_MulticastSettlement/validate_balance_after_withdrawbecause the selected seat had a zero USDC price override (effective_price = 0) while the client still paidparsedAmount = 30_000_000at pay time and got it all back on withdraw. The accounting invariantrefund + retained == effective_priceevaluated to30_000_000 == 0and failed.parsedAmount(what was actually debited) instead ofeffectivePrice. Holds regardless of prorating or zero-override seats.effectivePrice == 0(nothing meaningful to assert about a free seat under prorating).refund < effective_price, which is the wrong way around. The correct invariant isretained < effective_price— the program kept less than a full epoch because the client left early.Testing Verification
paid=30_000_000, refund=30_000_000, retained=0, effective_price=0) and confirmed the new invariantparsedAmount == refund + retainedholds (30M == 30M + 0).refund > 0,retained > 0,retained < effective_price.