test(swap): enable Smart Transactions in swap and bridge E2E tests#27836
Conversation
Remove .withDisabledSmartTransactions() and wire up setupSmartTransactionsMocks across all swap/bridge regression and smoke specs. The STX mock forwards all rawTxs (approval + swap) to Anvil sequentially so both txs are mined and TransactionController can resolve receipts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
…ridge mock The getTxStatus mock in setupSmartTransactionsMocks was registered at priority 999, same as bridge-mocks.ts. Since mockttp resolves ties LIFO, the STX mock shadowed the bridge-specific one in bridge-action-smoke, incorrectly setting destChain.txHash equal to srcTxHash. Lower the STX getTxStatus mock to priority 1 so bridge-mocks.ts always wins for bridge tests. Same-chain swap tests are unaffected since srcChainId == destChainId and reusing srcTxHash for both chains is correct. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
davibroc
left a comment
There was a problem hiding this comment.
Addressed the cursor bot comment: the getTxStatus mock in setupSmartTransactionsMocks has been lowered to priority 1 (commit 8082888) so bridge-mocks.ts (priority 999) always takes precedence for bridge tests. Same-chain swap tests are unaffected since srcChainId == destChainId there.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokeTrade is selected because the directly modified tests are swap and bridge smoke/regression tests. SmokeConfirmations is required per SmokeTrade tag description: 'When selecting SmokeTrade for swap or bridge flows, also select SmokeConfirmations (transaction confirmations are part of the flow).' No other tags are impacted as changes are purely within swap/bridge test infrastructure with no app code modifications. Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |




Summary
tests/helpers/swap/smart-transactions-mocks.ts— a reusable helper that mocks the STX backend (/getFees,/submitTransactions,/batchStatus,/getTxStatus) and forwards signed transactions to Anvil so they get mined and receipts resolve correctly..withDisabledSmartTransactions()from all affected test fixtures so tests run with the same STX-enabled configuration as production.swap-action-regression,swap-token-chart,swap-token-rwa,swap-action-smoke, andbridge-action-smoke.How Smart Transactions work in tests
When STX is enabled the swap publish hook intercepts the transaction before broadcast:
POST /getFees→ mock returns a static fee schedule so the controller can sign the tx locally.POST /submitTransactions→ mock forwards allrawTxsto Anvil viaeth_sendRawTransaction(sequentially, preserving nonce order for approval + swap batches), then returns a UUID.mobileReturnTxHashAsap: truethe hook resolves immediately with the locally-computedtxHash— no polling needed.TransactionControllerpolls Anvil foreth_getTransactionReceiptusing that hash → Anvil returns a valid receipt → tx is marked Confirmed.Key fix: ERC-20 → ETH batch submissions
Previously the mock only forwarded
rawTxs[0](the approval tx) to Anvil. The swap tx (rawTxs[1]) was never mined, soTransactionControllernever found a receipt and the swap stayed Pending. The fix loops over all entries inrawTxsand forwards each one sequentially.Modified scripts
swap-action-regression— ETH→WETH and WETH→ETH swaps confirm end-to-endswap-token-chart— ETH→DAI swap from token chart confirmsswap-token-rwa— USDC→GOOGLON swap (CowSwap intent flow)swap-action-smoke— ETH→USDC and USDC→ETH swaps confirmbridge-action-smoke— ETH (Mainnet)→ETH (Base) bridge confirms🤖 Generated with Claude Code
Note
Low Risk
Low risk since changes are isolated to E2E test harnesses/mocks; main risk is increased flakiness if STX mock assumptions (fee schema, proxy matching, Anvil forwarding) diverge from app behavior.
Overview
Swap/bridge E2E tests now run with Smart Transactions enabled by removing
.withDisabledSmartTransactions()from affected fixtures.Adds
setupSmartTransactionsMocksto mock the STX backend (/getFees,/submitTransactions,/batchStatus, and a low-priority/getTxStatusfallback) and, crucially, forwards all submittedrawTxssequentially to Anvil viaeth_sendRawTransactionso batched approval+swap flows get mined and receipts resolve.Updates swap and bridge regression/smoke specs to wrap existing
testSpecificMockwith the new STX mocks (and bumps timeouts where needed).Written by Cursor Bugbot for commit 8082888. This will update automatically on new commits. Configure here.