From 8e9fe076489d02a8ab41cae0b7d828196be3cb16 Mon Sep 17 00:00:00 2001 From: seaona <54408225+seaona@users.noreply.github.com> Date: Thu, 9 Mar 2023 14:37:29 +0100 Subject: [PATCH] [e2e] Check ENS resolves correctly (#18056) * ENS resolves correctly * Fix flaky test on firefox --- test/e2e/tests/ens.spec.js | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 test/e2e/tests/ens.spec.js diff --git a/test/e2e/tests/ens.spec.js b/test/e2e/tests/ens.spec.js new file mode 100644 index 000000000..d811db8fd --- /dev/null +++ b/test/e2e/tests/ens.spec.js @@ -0,0 +1,102 @@ +const { strict: assert } = require('assert'); +const { convertToHexValue, withFixtures } = require('../helpers'); +const FixtureBuilder = require('../fixture-builder'); + +describe('ENS', function () { + const sampleAddress = '1111111111111111111111111111111111111111'; + const sampleEnsDomain = 'test.eth'; + const infuraUrl = + 'https://mainnet.infura.io/v3/00000000000000000000000000000000'; + + async function mockInfura(mockServer) { + await mockServer.reset(); + await mockServer.forAnyRequest().thenPassThrough(); + await mockServer + .forPost(infuraUrl) + .withJsonBodyIncluding({ method: 'eth_blockNumber' }) + .thenCallback(() => { + return { + statusCode: 200, + json: { + jsonrpc: '2.0', + id: '1111111111111111', + result: '0x1', + }, + }; + }); + + await mockServer + .forPost(infuraUrl) + .withJsonBodyIncluding({ method: 'eth_call' }) + .thenCallback(() => { + return { + statusCode: 200, + json: { + jsonrpc: '2.0', + id: '1111111111111111', + result: `0x000000000000000000000000${sampleAddress}`, + }, + }; + }); + } + const ganacheOptions = { + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + + it('domain resolves to a correct address', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions, + title: this.test.title, + testSpecificMock: mockInfura, + }, + async ({ driver }) => { + await driver.navigate(); + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + await driver.waitForElementNotPresent('.loading-overlay'); + await driver.clickElement('.network-display'); + await driver.clickElement({ text: 'Ethereum Mainnet', tag: 'span' }); + + await driver.clickElement('[data-testid="eth-overview-send"]'); + + await driver.fill( + 'input[placeholder="Search, public address (0x), or ENS"]', + sampleEnsDomain, + ); + + await driver.clickElement( + '.send__select-recipient-wrapper__group-item__title', + ); + + const currentEnsDomain = await driver.findElement( + '.ens-input__selected-input__title', + ); + + assert.equal( + await currentEnsDomain.getText(), + 'test.eth', + 'Domain name not correct', + ); + + const resolvedAddress = await driver.findElement( + '.ens-input__selected-input__subtitle', + ); + + assert.equal( + await resolvedAddress.getText(), + `0x${sampleAddress}`, + 'Resolved address not correct', + ); + }, + ); + }); +});