-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix: flaky test Settings Redirects to ENS domains when user inputs ENS into address bar
#24898
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
27cadfb
add fixtures and mocks
seaona 7ef4782
add http
seaona bb7fcb6
Merge branch 'develop' into flaky-ens-redirect
danjm 5da3ac2
Merge branch 'develop' into flaky-ens-redirect
hjetpoluru f9e112d
Update test/e2e/webdriver/chrome.js
seaona be460de
move const inside func
seaona 2348da1
Merge branch 'develop' into flaky-ens-redirect
seaona 34aac81
Merge branch 'develop' into flaky-ens-redirect
legobeat 852ccdf
Merge branch 'develop' into flaky-ens-redirect
seaona 2fe41ee
Merge branch 'develop' into flaky-ens-redirect
HowardBraham 0c255ca
mitigate redirect flakiness action with max value
seaona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,151 @@ | ||
const { buildWebDriver } = require('../../webdriver'); | ||
const { withFixtures, tinyDelayMs, unlockWallet } = require('../../helpers'); | ||
const { | ||
defaultGanacheOptions, | ||
tinyDelayMs, | ||
unlockWallet, | ||
withFixtures, | ||
} = require('../../helpers'); | ||
const FixtureBuilder = require('../../fixture-builder'); | ||
const { mockServerJsonRpc } = require('../ppom/mocks/mock-server-json-rpc'); | ||
|
||
const BALANCE_CHECKER = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39'; | ||
const ENS_PUBLIC_RESOLVER = '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41'; | ||
const ENS_REGISTRY_WITH_FALLBACK = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'; | ||
|
||
async function mockInfura(mockServer) { | ||
await mockServerJsonRpc(mockServer, [ | ||
[ | ||
'eth_blockNumber', | ||
{ | ||
methodResultVariant: 'custom', | ||
}, | ||
], | ||
['eth_estimateGas'], | ||
['eth_feeHistory'], | ||
['eth_gasPrice'], | ||
['eth_getBalance'], | ||
['eth_getBlockByNumber'], | ||
['eth_getTransactionCount'], | ||
['net_version'], | ||
]); | ||
|
||
// Resolver Call | ||
await mockServer | ||
.forPost() | ||
.withJsonBodyIncluding({ | ||
method: 'eth_call', | ||
params: [ | ||
{ | ||
to: ENS_REGISTRY_WITH_FALLBACK, | ||
}, | ||
], | ||
}) | ||
.thenCallback(async (req) => { | ||
return { | ||
statusCode: 200, | ||
json: { | ||
jsonrpc: '2.0', | ||
id: (await req.body.getJson()).id, | ||
result: | ||
'0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', | ||
}, | ||
}; | ||
}); | ||
|
||
// Supports Interface Call | ||
await mockServer | ||
.forPost() | ||
.withJsonBodyIncluding({ | ||
method: 'eth_call', | ||
params: [ | ||
{ | ||
data: '0x01ffc9a7bc1c58d100000000000000000000000000000000000000000000000000000000', | ||
to: ENS_PUBLIC_RESOLVER, | ||
}, | ||
], | ||
}) | ||
.thenCallback(async (req) => { | ||
return { | ||
statusCode: 200, | ||
json: { | ||
jsonrpc: '2.0', | ||
id: (await req.body.getJson()).id, | ||
result: | ||
'0x0000000000000000000000000000000000000000000000000000000000000001', | ||
}, | ||
}; | ||
}); | ||
|
||
// Supports Interface Call | ||
await mockServer | ||
.forPost() | ||
.withJsonBodyIncluding({ | ||
method: 'eth_call', | ||
params: [ | ||
{ | ||
data: '0x01ffc9a7d8389dc500000000000000000000000000000000000000000000000000000000', | ||
to: ENS_PUBLIC_RESOLVER, | ||
}, | ||
], | ||
}) | ||
.thenCallback(async (req) => { | ||
return { | ||
statusCode: 200, | ||
json: { | ||
jsonrpc: '2.0', | ||
id: (await req.body.getJson()).id, | ||
result: | ||
'0x0000000000000000000000000000000000000000000000000000000000000000', | ||
}, | ||
}; | ||
}); | ||
|
||
// Content Hash Call | ||
await mockServer | ||
.forPost() | ||
.withJsonBodyIncluding({ | ||
method: 'eth_call', | ||
params: [ | ||
{ | ||
data: '0xbc1c58d1e650784434622eeb4ffbbb3220ebb371e26ad1a77f388680d42d8b1624baa6df', | ||
to: ENS_PUBLIC_RESOLVER, | ||
}, | ||
], | ||
}) | ||
.thenCallback(async (req) => { | ||
return { | ||
statusCode: 200, | ||
json: { | ||
jsonrpc: '2.0', | ||
id: (await req.body.getJson()).id, | ||
result: | ||
'0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000', | ||
}, | ||
}; | ||
}); | ||
|
||
// Token Balance Call | ||
await mockServer | ||
.forPost() | ||
.withJsonBodyIncluding({ | ||
method: 'eth_call', | ||
params: [ | ||
{ | ||
to: BALANCE_CHECKER, | ||
}, | ||
], | ||
}) | ||
.thenCallback(async (req) => { | ||
return { | ||
statusCode: 200, | ||
json: { | ||
jsonrpc: '2.0', | ||
id: (await req.body.getJson()).id, | ||
result: | ||
'0x0000000000000000000000000000000000000000000000000000000000000000', | ||
}, | ||
}; | ||
}); | ||
} | ||
|
||
describe('Settings', function () { | ||
const ENS_NAME = 'metamask.eth'; | ||
|
@@ -10,25 +155,38 @@ describe('Settings', function () { | |
it('Redirects to ENS domains when user inputs ENS into address bar', async function () { | ||
// Using proxy port that doesn't resolve so that the browser can error out properly | ||
// on the ".eth" hostname. The proxy does too much interference with 8000. | ||
const { driver } = await buildWebDriver({ proxyUrl: '127.0.0.1:8001' }); | ||
await driver.navigate(); | ||
|
||
// The setting defaults to "on" so we can simply enter an ENS address | ||
// into the address bar and listen for address change | ||
try { | ||
await driver.openNewPage(ENS_NAME_URL); | ||
} catch (e) { | ||
// Ignore ERR_PROXY_CONNECTION_FAILED error | ||
// since all we care about is getting to the correct URL | ||
} | ||
|
||
// Ensure that the redirect to ENS Domains has happened | ||
await driver.wait(async () => { | ||
const currentUrl = await driver.getCurrentUrl(); | ||
return currentUrl === ENS_DESTINATION_URL; | ||
}, tinyDelayMs); | ||
|
||
await driver.quit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to start or stop the driver manually, as now it's done within the fixtures |
||
|
||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder().withNetworkControllerOnMainnet().build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test.title, | ||
testSpecificMock: mockInfura, | ||
driverOptions: { | ||
proxyPort: '8001', | ||
}, | ||
}, | ||
async ({ driver }) => { | ||
await driver.navigate(); | ||
|
||
// The setting defaults to "on" so we can simply enter an ENS address | ||
// into the address bar and listen for address change | ||
try { | ||
await driver.openNewPage(ENS_NAME_URL); | ||
} catch (e) { | ||
// Ignore ERR_PROXY_CONNECTION_FAILED error | ||
// since all we care about is getting to the correct URL | ||
} | ||
|
||
// Ensure that the redirect to ENS Domains has happened | ||
await driver.wait(async () => { | ||
const currentUrl = await driver.getCurrentUrl(); | ||
return currentUrl === ENS_DESTINATION_URL; | ||
}, 10000); | ||
// Setting a large delay has proven to stabilize the flakiness of the redirect | ||
// and it's only a MAX value | ||
}, | ||
); | ||
}); | ||
|
||
it('Does not fetch ENS data for ENS Domain when ENS and IPFS switched off', async function () { | ||
|
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to preserve the proxy number, we now pass this as an option in fixtures, and forward it to the chrome/firefox drivers as an option