2022-10-10 23:59:58 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2023-05-30 15:48:43 +02:00
|
|
|
const {
|
|
|
|
convertToHexValue,
|
|
|
|
withFixtures,
|
2023-06-09 16:01:12 +02:00
|
|
|
logInWithBalanceValidation,
|
2023-05-30 15:48:43 +02:00
|
|
|
} = require('../helpers');
|
2022-10-28 10:42:12 +02:00
|
|
|
const FixtureBuilder = require('../fixture-builder');
|
2022-10-10 23:59:58 +02:00
|
|
|
|
|
|
|
describe('Gas API fallback', function () {
|
|
|
|
async function mockGasApiDown(mockServer) {
|
|
|
|
await mockServer
|
|
|
|
.forGet(
|
2023-06-13 16:43:13 +02:00
|
|
|
'https://gas-api.metaswap.codefi.network/networks/1337/suggestedGasFees',
|
2022-10-10 23:59:58 +02:00
|
|
|
)
|
2023-04-19 16:36:23 +02:00
|
|
|
.always()
|
2022-10-10 23:59:58 +02:00
|
|
|
.thenCallback(() => {
|
|
|
|
return {
|
2022-12-08 19:37:06 +01:00
|
|
|
statusCode: 200,
|
|
|
|
json: {
|
|
|
|
low: {
|
|
|
|
minWaitTimeEstimate: 180000,
|
|
|
|
maxWaitTimeEstimate: 300000,
|
|
|
|
suggestedMaxPriorityFeePerGas: '3',
|
|
|
|
suggestedMaxFeePerGas: '53',
|
|
|
|
},
|
|
|
|
medium: {
|
|
|
|
minWaitTimeEstimate: 15000,
|
|
|
|
maxWaitTimeEstimate: 60000,
|
|
|
|
suggestedMaxPriorityFeePerGas: '7',
|
|
|
|
suggestedMaxFeePerGas: '70',
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
minWaitTimeEstimate: 0,
|
|
|
|
maxWaitTimeEstimate: 15000,
|
|
|
|
suggestedMaxPriorityFeePerGas: '10',
|
|
|
|
suggestedMaxFeePerGas: '100',
|
|
|
|
},
|
|
|
|
estimatedBaseFee: '50',
|
|
|
|
networkCongestion: 0.9,
|
|
|
|
latestPriorityFeeRange: ['1', '20'],
|
|
|
|
historicalPriorityFeeRange: ['2', '125'],
|
|
|
|
historicalBaseFeeRange: ['50', '100'],
|
|
|
|
priorityFeeTrend: 'up',
|
|
|
|
baseFeeTrend: 'down',
|
|
|
|
},
|
2022-10-10 23:59:58 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const ganacheOptions = {
|
|
|
|
hardfork: 'london',
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
|
|
balance: convertToHexValue(25000000000000000000),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2022-12-08 19:37:06 +01:00
|
|
|
it('network error message is displayed if network is congested', async function () {
|
2022-10-10 23:59:58 +02:00
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder().build(),
|
2022-10-10 23:59:58 +02:00
|
|
|
testSpecificMock: mockGasApiDown,
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
2023-06-08 15:21:21 +02:00
|
|
|
async ({ driver, ganacheServer }) => {
|
2022-10-10 23:59:58 +02:00
|
|
|
await driver.navigate();
|
2023-06-09 16:01:12 +02:00
|
|
|
await logInWithBalanceValidation(driver, ganacheServer);
|
2022-10-10 23:59:58 +02:00
|
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
|
|
|
|
|
|
|
await driver.fill(
|
2023-06-08 19:09:39 +02:00
|
|
|
'input[placeholder="Enter public address (0x) or ENS name"]',
|
2022-10-10 23:59:58 +02:00
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
);
|
|
|
|
|
|
|
|
const inputAmount = await driver.findElement('.unit-input__input');
|
|
|
|
await inputAmount.fill('1');
|
|
|
|
|
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
|
2023-05-30 15:48:43 +02:00
|
|
|
await driver.findElement('.transaction-alerts');
|
|
|
|
|
2022-12-08 19:37:06 +01:00
|
|
|
const error = await driver.isElementPresent({
|
|
|
|
text: 'Network is busy. Gas prices are high and estimates are less accurate.',
|
|
|
|
});
|
2022-10-10 23:59:58 +02:00
|
|
|
|
2022-12-08 19:37:06 +01:00
|
|
|
assert.equal(error, true, 'Network error is present');
|
2022-10-10 23:59:58 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|