Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(TXL-308): initial e2e for stx using swaps #27215

Merged
merged 17 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions privacy-snapshot.json
Copy link
Member

Choose a reason for hiding this comment

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

Where are these calls coming from?

Copy link
Member

Choose a reason for hiding this comment

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

I see that transaction.api.cx.metamask.io is used for smart transactions, and has e2e fetch mocks.

But it's unclear to me why the other two domains have been added, and I don't see any mocks for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @Gudahtt, thanks for flagging those suspicious URLs—they're fixed in commit b8aa011.

The verify.walletconnect.com request was coming from createWeb3Modal in the e2e test dapp. There were some remnants from an earlier e2e implementation intercepting socket connections, which caused this connection to register.

We should consider including socket requests in our privacy snapshot.

Let me know if you have any thoughts on this.

Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
"api.web3modal.com",
"app.ens.domains",
"arbitrum-mainnet.infura.io",
"authentication.api.cx.metamask.io",
"bafkreifvhjdf6ve4jfv6qytqtux5nd4nwnelioeiqx5x2ez5yrgrzk7ypi.ipfs.dweb.link",
"bafybeidxfmwycgzcp4v2togflpqh2gnibuexjy4m4qqwxp7nh3jx5zlh4y.ipfs.dweb.link",
"bridge.api.cx.metamask.io",
"cdn.segment.com",
"cdn.segment.io",
"cdnjs.cloudflare.com",
"chainid.network",
"client-side-detection.api.cx.metamask.io",
"configuration.dev.metamask-institutional.io",
"configuration.metamask-institutional.io",
"connect.trezor.io",
"crypto.com",
"customnetwork.test",
"doesntexist.test",
"etherscan.io",
Expand All @@ -24,18 +27,20 @@
"gas.api.cx.metamask.io",
"github.com",
"goerli.infura.io",
"lattice.gridplus.io",
"localhost:8000",
"localhost:8545",
"mainnet.infura.io",
"metamask.eth",
"metamask.github.io",
"min-api.cryptocompare.com",
"nft.api.cx.metamask.io",
"oidc.api.cx.metamask.io",
"on-ramp-content.api.cx.metamask.io",
"on-ramp-content.uat-api.cx.metamask.io",
"phishing-detection.api.cx.metamask.io",
"portfolio.metamask.io",
"price.api.cx.metamask.io",
"on-ramp-content.api.cx.metamask.io",
"on-ramp-content.uat-api.cx.metamask.io",
"proxy.api.cx.metamask.io",
"raw.githubusercontent.com",
"registry.npmjs.org",
Expand All @@ -49,15 +54,11 @@
"test.metamask-phishing.io",
"token.api.cx.metamask.io",
"tokens.api.cx.metamask.io",
"transaction.api.cx.metamask.io",
"tx-sentinel-ethereum-mainnet.api.cx.metamask.io",
"unresponsive-rpc.url",
"www.4byte.directory",
"lattice.gridplus.io",
"unresponsive-rpc.test",
"authentication.api.cx.metamask.io",
"oidc.api.cx.metamask.io",
"price.api.cx.metamask.io",
"token.api.cx.metamask.io",
"client-side-detection.api.cx.metamask.io",
"user-storage.api.cx.metamask.io"
"unresponsive-rpc.url",
"user-storage.api.cx.metamask.io",
"verify.walletconnect.com",
"www.4byte.directory"
]
2 changes: 2 additions & 0 deletions test/e2e/default-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
SmartTransactionsController: {
smartTransactionsState: {
fees: {},
feesByChainId: {},
liveness: true,
livenessByChainId: {},
smartTransactions: {
[CHAIN_IDS.MAINNET]: [],
},
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ class FixtureBuilder {
});
}

withPreferencesControllerSmartTransactionsOptedIn() {
return this.withPreferencesController({
preferences: {
smartTransactionsOptInStatus: true,
},
});
}

withPreferencesControllerAndFeatureFlag(flags) {
merge(this.fixture.data.PreferencesController, flags);
return this;
Expand Down
64 changes: 36 additions & 28 deletions test/e2e/mock-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,35 +268,38 @@ async function setupMocking(
.thenCallback(() => {
return {
statusCode: 200,
json: [
{
ethereum: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
bsc: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
polygon: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
avalanche: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
smartTransactions: {
mobileActive: false,
extensionActive: false,
},
updated_at: '2022-03-17T15:54:00.360Z',
json: {
ethereum: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
],
bsc: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
polygon: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
avalanche: {
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
localhost: {
dbrans marked this conversation as resolved.
Show resolved Hide resolved
fallbackToV1: false,
mobileActive: true,
extensionActive: true,
},
smartTransactions: {
mobileActive: false,
extensionActive: true,
},
updated_at: '2022-03-17T15:54:00.360Z',
},
};
});

Expand Down Expand Up @@ -664,6 +667,11 @@ async function setupMocking(
const portfolioRequestsMatcher = (request) =>
request.headers.referer === 'https://portfolio.metamask.io/';

// Passthrough requests to ServerMochaToBackground's WebSocket server
// which is running on port 8111.
// TODO: forAnyWebSocket() is too broad, we should be able to more
// specifically target ServerMochaToBackground's WebSocket server
await server.forAnyWebSocket().thenPassThrough();
/**
* Listen for requests and add the hostname to the privacy report if it did
* not previously exist. This is used to track which hosts are requested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,8 @@
"bridgeState": {
"bridgeFeatureFlags": {
"extensionSupport": "boolean",
"srcNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
},
"destNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
}
"srcNetworkAllowlist": { "0": "string", "1": "string", "2": "string" },
"destNetworkAllowlist": { "0": "string", "1": "string", "2": "string" }
}
}
},
Expand Down Expand Up @@ -180,6 +172,7 @@
"permissionActivityLog": "object"
},
"PreferencesController": {
"selectedAddress": "string",
"useBlockie": false,
"useNonceField": false,
"usePhishDetect": true,
Expand Down Expand Up @@ -228,8 +221,7 @@
"useExternalNameSources": "boolean",
"useTransactionSimulations": true,
"enableMV3TimestampSave": true,
"useExternalServices": "boolean",
"selectedAddress": "string"
"useExternalServices": "boolean"
},
"QueuedRequestController": { "queuedRequestCount": 0 },
"SelectedNetworkController": { "domains": "object" },
Expand All @@ -242,7 +234,9 @@
"SmartTransactionsController": {
"smartTransactionsState": {
"fees": {},
"feesByChainId": "object",
"liveness": true,
"livenessByChainId": "object",
"smartTransactions": "object"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
}
},
"keyrings": "object",
"selectedAddress": "string",
"useNonceField": false,
"usePhishDetect": true,
"dismissSeedBackUpReminder": true,
Expand Down Expand Up @@ -127,16 +128,15 @@
"useTransactionSimulations": true,
"enableMV3TimestampSave": true,
"useExternalServices": "boolean",
"selectedAddress": "string",
"metaMetricsId": "fake-metrics-id",
"marketingCampaignCookieId": null,
"metaMetricsDataDeletionId": null,
"metaMetricsDataDeletionTimestamp": 0,
"eventsBeforeMetricsOptIn": "object",
"traits": "object",
"previousUserTraits": "object",
"fragments": "object",
"segmentApiCalls": "object",
"metaMetricsDataDeletionId": null,
"metaMetricsDataDeletionTimestamp": 0,
"currentCurrency": "usd",
"alertEnabledness": { "unconnectedAccount": true, "web3ShimUsage": true },
"unconnectedAccountAlertShownOrigins": "object",
Expand Down Expand Up @@ -167,7 +167,9 @@
"allDetectedTokens": {},
"smartTransactionsState": {
"fees": {},
"feesByChainId": "object",
"liveness": true,
"livenessByChainId": "object",
"smartTransactions": "object"
},
"allNftContracts": "object",
Expand Down Expand Up @@ -248,16 +250,8 @@
"bridgeState": {
"bridgeFeatureFlags": {
"extensionSupport": "boolean",
"srcNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
},
"destNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
}
"srcNetworkAllowlist": { "0": "string", "1": "string", "2": "string" },
"destNetworkAllowlist": { "0": "string", "1": "string", "2": "string" }
}
},
"ensEntries": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@
},
"snapsInstallPrivacyWarningShown": true
},
"BridgeController": {
"bridgeState": {
"bridgeFeatureFlags": {
"extensionSupport": "boolean",
"srcNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
},
"destNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
}
}
}
},
"CurrencyController": {
"currentCurrency": "usd",
"currencyRates": {
Expand Down Expand Up @@ -80,11 +97,11 @@
},
"NetworkController": {
"selectedNetworkClientId": "string",
"networkConfigurations": "object",
"networksMetadata": {
"networkConfigurationId": { "EIPS": {}, "status": "available" }
},
"providerConfig": "object",
"networkConfigurations": "object"
"providerConfig": "object"
},
"OnboardingController": {
"completedOnboarding": true,
Expand Down Expand Up @@ -134,27 +151,12 @@
"SmartTransactionsController": {
"smartTransactionsState": {
"fees": {},
"feesByChainId": "object",
"liveness": true,
"livenessByChainId": "object",
"smartTransactions": "object"
}
},
"BridgeController": {
"bridgeState": {
"bridgeFeatureFlags": {
"extensionSupport": "boolean",
"srcNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
},
"destNetworkAllowlist": {
"0": "string",
"1": "string",
"2": "string"
}
}
}
},
"SubjectMetadataController": { "subjectMetadata": "object" },
"TokensController": {
"allDetectedTokens": {},
Expand Down
Loading