mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
abd2a5559e
* Update `@metamask/gas-fee-controller` to v6 The `@metamask/address-book-controller` package has been updated to v3. This version was part of the [core monorepo v53](MetaMask/core#1385) release. The remaining packages released as part of v53 will be updated in later PRs. This release included a number of breaking changes, but most of them do not affect the extension: * Bump to Node 16 * The extension already uses Node.js v16 * The `getChainId` constructor parameter now expects a `Hex` return type rather than a decimal string * The extension was already passing in a `getChainId` parameter that returned `Hex` * The gas fee controller messenger now requires the `NetworkController:stateChange` event instead of the `NetworkController:providerConfigChange` event * This does not apply if `onNetworkStateChange` and `getChainId` are provided to the constructor, which is the case here. * Update `@metamask/network-controller` dependency and peer dependency * This dependency is only used for types, and none of the type changes affect how the extension interacts with this controller. The one change that did have an impact is that the constructor parameter `onNetworkStateChange` now expects event handlers to be passed the full network state. Relates to #19271 * Ensure chainid always matches mainnet in test builds This is a bit strange, but this is how the tests were setup previously. * Fix accidental state mutation * Remove hardcoded mainnet chain ID from test builds
95 lines
2.8 KiB
JavaScript
95 lines
2.8 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const {
|
|
convertToHexValue,
|
|
withFixtures,
|
|
logInWithBalanceValidation,
|
|
} = require('../helpers');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
|
|
describe('Gas API fallback', function () {
|
|
async function mockGasApiDown(mockServer) {
|
|
await mockServer
|
|
.forGet(
|
|
'https://gas-api.metaswap.codefi.network/networks/1337/suggestedGasFees',
|
|
)
|
|
.always()
|
|
.thenCallback(() => {
|
|
return {
|
|
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',
|
|
},
|
|
};
|
|
});
|
|
}
|
|
|
|
const ganacheOptions = {
|
|
hardfork: 'london',
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
|
|
it('network error message is displayed if network is congested', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
testSpecificMock: mockGasApiDown,
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver, ganacheServer }) => {
|
|
await driver.navigate();
|
|
await logInWithBalanceValidation(driver, ganacheServer);
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
|
|
|
await driver.fill(
|
|
'input[placeholder="Enter public address (0x) or ENS name"]',
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
);
|
|
|
|
const inputAmount = await driver.findElement('.unit-input__input');
|
|
await inputAmount.fill('1');
|
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
await driver.findElement('.transaction-alerts');
|
|
|
|
const error = await driver.isElementPresent({
|
|
text: 'Network is busy. Gas prices are high and estimates are less accurate.',
|
|
});
|
|
|
|
assert.equal(error, true, 'Network error is present');
|
|
},
|
|
);
|
|
});
|
|
});
|