Skip to content

Commit c6abb14

Browse files
authored
test: Add SSE support and STX by default to all Swap/Bridge tests (#41468)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** - Enable Smart Transactions (STX) in bridge E2E tests by default, replacing the hardcoded opt-out in all fixtures - Add mockSmartTransactionsForBridge — mocks STX sentinel/fees/submit/batchStatus endpoints, forwarding raw txs to Anvil so receipts are genuine - Add SSE streaming support to all quote mocks (getQuoteStream) via sseEnabled flag - Fix mockGetTxStatus to use a distinct dest tx hash (required for BridgeStatusController to mark bridges complete) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Test infrastructure changes alter how Swap/Bridge E2E tests execute transactions (enabling STX by default and switching many quote mocks to SSE streams), which may introduce CI flakiness or new mock gaps despite being non-production code. > > **Overview** > **Swap/Bridge E2E tests now run with SSE quotes and Smart Transactions enabled by default.** Most test suites switch to `BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED`, update expected balances, and consolidate shared quote-entry logic into `enterBridgeQuote`. > > Bridge mocks are expanded to support both `getQuote` and `getQuoteStream` paths, and `mockGetTxStatus` now returns a distinct destination tx hash so bridges can reach `COMPLETE`. A new `mockSmartTransactionsForBridge` simulates STX sentinel/fees/submit/batchStatus, forwarding raw signed txs to the local Anvil node to produce real receipts; fixtures/manifest flags are updated to include STX network configs (Mainnet + Linea) and only opt out when explicitly requested. > > Also updates test data (`swap-quotes-eth-musd.json` tx `value` formatting) and adds `tx-sentinel-linea-mainnet.api.cx.metamask.io` to `privacy-snapshot.json`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a7bf5c8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 9fcd87d commit c6abb14

8 files changed

Lines changed: 527 additions & 106 deletions

File tree

privacy-snapshot.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"tron-mainnet.infura.io",
134134
"tx-sentinel-bsc-mainnet.api.cx.metamask.io",
135135
"tx-sentinel-ethereum-mainnet.api.cx.metamask.io",
136+
"tx-sentinel-linea-mainnet.api.cx.metamask.io",
136137
"unresponsive-rpc.test",
137138
"unresponsive-rpc.url",
138139
"user-storage.api.cx.metamask.io",

test/e2e/tests/bridge/bridge-L2-tests.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { Suite } from 'mocha';
22
import { withFixtures } from '../../helpers';
33
import { login } from '../../page-objects/flows/login.flow';
4-
import { DEFAULT_BRIDGE_FEATURE_FLAGS } from './constants';
4+
import { BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED } from './constants';
55
import { bridgeTransaction, getBridgeL2Fixtures } from './bridge-test-utils';
66

77
describe('Bridge tests', function (this: Suite) {
88
this.timeout(120000); // Needs a higher timeout as it's a longer tests
99
it('should execute bridge transactions on L2 networks', async function () {
1010
await withFixtures(
11-
getBridgeL2Fixtures(this.test?.fullTitle(), DEFAULT_BRIDGE_FEATURE_FLAGS),
11+
getBridgeL2Fixtures(
12+
this.test?.fullTitle(),
13+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
14+
true,
15+
),
1216
async ({ driver }) => {
13-
await login(driver, { expectedBalance: '$225,750.00' });
17+
await login(driver, { expectedBalance: '$225,730.11' });
1418

1519
await bridgeTransaction({
1620
driver,

test/e2e/tests/bridge/bridge-negative-cases.spec.ts

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Suite } from 'mocha';
22
import { withFixtures } from '../../helpers';
33
import { login } from '../../page-objects/flows/login.flow';
44
import HomePage from '../../page-objects/pages/home/homepage';
5-
import { Driver } from '../../webdriver/driver';
65
import BridgeQuotePage from '../../page-objects/pages/bridge/quote-page';
76
import ActivityListPage from '../../page-objects/pages/home/activity-list';
87
import {
8+
enterBridgeQuote,
99
getBridgeNegativeCasesFixtures,
1010
getInsufficientFundsFixtures,
1111
getQuoteNegativeCasesFixtures,
@@ -14,7 +14,7 @@ import {
1414
GET_QUOTE_INVALID_RESPONSE,
1515
FAILED_SOURCE_TRANSACTION,
1616
FAILED_DEST_TRANSACTION,
17-
DEFAULT_BRIDGE_FEATURE_FLAGS,
17+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
1818
} from './constants';
1919

2020
const DEFAULT_LOCAL_NODE_USD_BALANCE = '24.998';
@@ -24,7 +24,7 @@ describe('Bridge functionality', function (this: Suite) {
2424
await withFixtures(
2525
{
2626
...getInsufficientFundsFixtures(
27-
DEFAULT_BRIDGE_FEATURE_FLAGS,
27+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
2828
this.test?.fullTitle(),
2929
),
3030
},
@@ -59,7 +59,7 @@ describe('Bridge functionality', function (this: Suite) {
5959
statusCode: 500,
6060
json: 'Internal server error',
6161
},
62-
DEFAULT_BRIDGE_FEATURE_FLAGS,
62+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
6363
this.test?.fullTitle(),
6464
),
6565
},
@@ -86,7 +86,7 @@ describe('Bridge functionality', function (this: Suite) {
8686
statusCode: 200,
8787
json: [],
8888
},
89-
DEFAULT_BRIDGE_FEATURE_FLAGS,
89+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
9090
this.test?.fullTitle(),
9191
),
9292
},
@@ -113,7 +113,7 @@ describe('Bridge functionality', function (this: Suite) {
113113
statusCode: 200,
114114
json: GET_QUOTE_INVALID_RESPONSE,
115115
},
116-
DEFAULT_BRIDGE_FEATURE_FLAGS,
116+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
117117
this.test?.fullTitle(),
118118
),
119119
},
@@ -141,7 +141,7 @@ describe('Bridge functionality', function (this: Suite) {
141141
statusCode: 500,
142142
json: 'Internal server error',
143143
},
144-
DEFAULT_BRIDGE_FEATURE_FLAGS,
144+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
145145
this.test?.fullTitle(),
146146
),
147147
},
@@ -157,8 +157,8 @@ describe('Bridge functionality', function (this: Suite) {
157157

158158
const bridgePage = await enterBridgeQuote(driver);
159159
await bridgePage.submitQuote();
160-
161160
await homePage.goToActivityList();
161+
162162
const activityList = new ActivityListPage(driver);
163163
await activityList.checkPendingBridgeTransactionActivity();
164164
await activityList.checkBridgeTransactionDetails(
@@ -180,8 +180,10 @@ describe('Bridge functionality', function (this: Suite) {
180180
statusCode: 200,
181181
json: FAILED_SOURCE_TRANSACTION,
182182
},
183-
DEFAULT_BRIDGE_FEATURE_FLAGS,
183+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
184184
this.test?.fullTitle(),
185+
true,
186+
{ minedTx: 'reverted' },
185187
),
186188
},
187189
async ({ driver, localNodes }) => {
@@ -196,7 +198,6 @@ describe('Bridge functionality', function (this: Suite) {
196198

197199
const bridgePage = await enterBridgeQuote(driver);
198200
await bridgePage.submitQuote();
199-
200201
await homePage.goToActivityList();
201202

202203
const activityList = new ActivityListPage(driver);
@@ -220,8 +221,10 @@ describe('Bridge functionality', function (this: Suite) {
220221
statusCode: 200,
221222
json: FAILED_DEST_TRANSACTION,
222223
},
223-
DEFAULT_BRIDGE_FEATURE_FLAGS,
224+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
224225
this.test?.fullTitle(),
226+
true,
227+
{ minedTx: 'reverted' },
225228
),
226229
},
227230
async ({ driver, localNodes }) => {
@@ -236,7 +239,6 @@ describe('Bridge functionality', function (this: Suite) {
236239

237240
const bridgePage = await enterBridgeQuote(driver);
238241
await bridgePage.submitQuote();
239-
240242
await homePage.goToActivityList();
241243

242244
const activityList = new ActivityListPage(driver);
@@ -252,16 +254,3 @@ describe('Bridge functionality', function (this: Suite) {
252254
);
253255
});
254256
});
255-
256-
async function enterBridgeQuote(driver: Driver): Promise<BridgeQuotePage> {
257-
const bridgePage = new BridgeQuotePage(driver);
258-
await bridgePage.enterBridgeQuote({
259-
amount: '1',
260-
tokenFrom: 'ETH',
261-
tokenTo: 'ETH',
262-
fromChain: 'Ethereum',
263-
toChain: 'Linea',
264-
});
265-
266-
return bridgePage;
267-
}

test/e2e/tests/bridge/bridge-positive-cases.spec.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import HomePage from '../../page-objects/pages/home/homepage';
55
import BridgeQuotePage from '../../page-objects/pages/bridge/quote-page';
66
import NetworkManager from '../../page-objects/pages/network-manager';
77
import TokenOverviewPage from '../../page-objects/pages/token-overview-page';
8-
import {
9-
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
10-
DEFAULT_BRIDGE_FEATURE_FLAGS,
11-
} from './constants';
8+
import { BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED } from './constants';
129
import {
1310
bridgeTransaction,
1411
checkQuoteRequestsAreNotMadeAfterTimestamp,
@@ -21,15 +18,14 @@ describe('Bridge tests', function (this: Suite) {
2118
await withFixtures(
2219
getBridgeFixtures(
2320
this.test?.fullTitle(),
24-
DEFAULT_BRIDGE_FEATURE_FLAGS,
21+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
2522
false,
2623
),
2724
async ({ driver }) => {
2825
// the balance has been fixed now , we show native balance when currency controller is set
2926
await login(driver, { expectedBalance: '$225,730.11' });
3027

3128
const homePage = new HomePage(driver);
32-
3329
await bridgeTransaction({
3430
driver,
3531
quote: {
@@ -94,7 +90,7 @@ describe('Bridge tests', function (this: Suite) {
9490
await withFixtures(
9591
getBridgeFixtures(
9692
this.test?.fullTitle(),
97-
DEFAULT_BRIDGE_FEATURE_FLAGS,
93+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
9894
false,
9995
),
10096
async ({ driver, mockedEndpoint }) => {
@@ -179,7 +175,7 @@ describe('Bridge tests', function (this: Suite) {
179175
await withFixtures(
180176
getBridgeFixtures(
181177
this.test?.fullTitle(),
182-
DEFAULT_BRIDGE_FEATURE_FLAGS,
178+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
183179
false,
184180
),
185181
async ({ driver }) => {
@@ -209,7 +205,7 @@ describe('Bridge tests', function (this: Suite) {
209205
await withFixtures(
210206
getBridgeFixtures(
211207
this.test?.fullTitle(),
212-
DEFAULT_BRIDGE_FEATURE_FLAGS,
208+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
213209
false,
214210
),
215211
async ({ driver }) => {
@@ -242,7 +238,7 @@ describe('Bridge tests', function (this: Suite) {
242238
await withFixtures(
243239
getBridgeFixtures(
244240
this.test?.fullTitle(),
245-
DEFAULT_BRIDGE_FEATURE_FLAGS,
241+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
246242
false,
247243
),
248244
async ({ driver }) => {
@@ -279,7 +275,7 @@ describe('Bridge tests', function (this: Suite) {
279275
await withFixtures(
280276
getBridgeFixtures(
281277
this.test?.fullTitle(),
282-
DEFAULT_BRIDGE_FEATURE_FLAGS,
278+
BRIDGE_FEATURE_FLAGS_WITH_SSE_ENABLED,
283279
false,
284280
),
285281
async ({ driver }) => {

0 commit comments

Comments
 (0)