Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alert users when the network is busy (#12268)
When a lot of transactions are occurring on the network, such as during an NFT drop, it drives gas fees up. When this happens, we want to not only inform the user about this, but also dissuade them from using a higher gas fee (as we have proved in testing that high gas fees can cause bidding wars and exacerbate the situation). The method for determining whether the network is "busy" is already handled by GasFeeController, which exposes a `networkCongestion` property within the gas fee estimate data. If this number exceeds 0.66 — meaning that the current base fee is above the 66th percentile among the base fees over the last several days — then we determine that the network is "busy".
- Loading branch information
Showing
15 changed files
with
430 additions
and
186 deletions.
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
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
38 changes: 38 additions & 0 deletions
38
ui/components/app/edit-gas-display/edit-gas-display.test.js
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { renderWithProvider } from '../../../../test/jest'; | ||
import configureStore from '../../../store/store'; | ||
import EditGasDisplay from '.'; | ||
|
||
jest.mock('../../../selectors'); | ||
jest.mock('../../../helpers/utils/confirm-tx.util'); | ||
jest.mock('../../../helpers/utils/transactions.util'); | ||
|
||
function render({ componentProps = {} } = {}) { | ||
const store = configureStore({}); | ||
return renderWithProvider(<EditGasDisplay {...componentProps} />, store); | ||
} | ||
|
||
describe('EditGasDisplay', () => { | ||
describe('if getIsNetworkBusy returns a truthy value', () => { | ||
it('informs the user', () => { | ||
render({ componentProps: { isNetworkBusy: true } }); | ||
expect( | ||
screen.getByText( | ||
'Network is busy. Gas prices are high and estimates are less accurate.', | ||
), | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('if getIsNetworkBusy does not return a truthy value', () => { | ||
it('does not inform the user', () => { | ||
render({ componentProps: { isNetworkBusy: false } }); | ||
expect( | ||
screen.queryByText( | ||
'Network is busy. Gas prices are high and estimates are less accurate.', | ||
), | ||
).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.