Skip to content

test(swap): add gasless swap e2e tests for ETH/USDC to MUSD with 7702 support#27895

Merged
davibroc merged 10 commits into
mainfrom
test/gasless-swap
Mar 26, 2026
Merged

test(swap): add gasless swap e2e tests for ETH/USDC to MUSD with 7702 support#27895
davibroc merged 10 commits into
mainfrom
test/gasless-swap

Conversation

@davibroc

@davibroc davibroc commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Expand gasless-swap.spec.ts with three test scenarios:
    • ETH → MUSD (gasless of native token, gasIncluded: true)
    • USDC → MUSD (gasless with ERC-20 approval, gasIncluded: true)
    • ETH → MUSD via 7702 (gasIncluded7702: true)

Note

Medium Risk
Medium risk because it monkey-patches mockttp matching behavior to suppress Error('Aborted') and expands E2E mocking/fixtures; mistakes could hide real errors or affect unrelated tests.

Overview
Adds new gasless swap smoke test scenarios for MUSD, including a live (non-skipped) ETH → MUSD flow using gasIncluded7702, plus two additional (currently skipped) cases for standard gasless ETH → MUSD and USDC → MUSD with approval.

Extends swap test fixtures/mocks to support MUSD (token lists, tokens API response, spot prices) and introduces dedicated quote fixtures for gasless and 7702 quotes (including txFee fields required by validators/UI).

Hardens E2E mocking by patching mockttp’s matchesAll to treat Error('Aborted') as a non-match, preventing aborted client requests from surfacing as unhandled rejections in Jest, and simplifies swap activity checking by removing an explicit post-toast delay.

Written by Cursor Bugbot for commit a0acb80. This will update automatically on new commits. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-qa QA team label Mar 24, 2026
@github-actions github-actions Bot added size-L risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 24, 2026
Comment thread tests/smoke/swap/gasless-swap.spec.ts
@davibroc davibroc added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 25, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 25, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
davibroc and others added 3 commits March 25, 2026 10:40
swapTestSpecificMock registers an empty-string SSE response for MUSD at
the default priority 999. In mockttp, FIFO wins at equal priority, so the
override calls in the gasless spec were silently losing the race. Passing
priority 1000 ensures the actual quote fixture is served.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@davibroc davibroc force-pushed the test/gasless-swap branch from fe554dd to 8bde2e0 Compare March 25, 2026 18:58
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Comment thread tests/helpers/swap/smart-transactions-mocks.ts Outdated
…ody read to handler

Monkey-patch mockttp's CallbackMatcher.matches() to pass the OngoingRequest
directly to the callback instead of awaiting waitForCompletedRequest(). This
eliminates streamToBuffer calls during rule matching, preventing unhandled
'Aborted' rejections when clients drop connections mid-request.

Move the request body read (rawTxs extraction) from the .matching() callback
into the .thenCallback() handler where body buffering is safe and fully caught.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@davibroc davibroc requested a review from a team as a code owner March 25, 2026 20:03
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Comment thread tests/api-mocking/MockServerE2E.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Comment thread tests/helpers/swap/constants.ts
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Comment thread tests/helpers/swap/swap-unified-ui.ts Outdated
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
Comment thread tests/helpers/swap/swap-unified-ui.ts
@davibroc davibroc added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Mar 26, 2026
@github-actions github-actions Bot removed the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@github-actions github-actions Bot added the risk-high Extensive testing required · High bug introduction risk label Mar 26, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread tests/helpers/swap/constants.ts
@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

@davibroc davibroc enabled auto-merge March 26, 2026 02:57
@davibroc davibroc added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit 65c4658 Mar 26, 2026
124 of 156 checks passed
@davibroc davibroc deleted the test/gasless-swap branch March 26, 2026 17:33
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-high Extensive testing required · High bug introduction risk size-L skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants