You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
653 lines
18 KiB
653 lines
18 KiB
4 years ago
|
import {
|
||
6 years ago
|
getCustomGasLimit,
|
||
|
getCustomGasPrice,
|
||
|
getRenderableBasicEstimateData,
|
||
6 years ago
|
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
||
4 years ago
|
isCustomPriceSafe,
|
||
4 years ago
|
isCustomPriceExcessive,
|
||
4 years ago
|
} from './custom-gas';
|
||
6 years ago
|
|
||
4 years ago
|
describe('custom-gas selectors', () => {
|
||
|
describe('getCustomGasPrice()', () => {
|
||
|
it('should return gas.customData.price', () => {
|
||
4 years ago
|
const mockState = { gas: { customData: { price: 'mockPrice' } } };
|
||
4 years ago
|
expect(getCustomGasPrice(mockState)).toStrictEqual('mockPrice');
|
||
4 years ago
|
});
|
||
|
});
|
||
4 years ago
|
describe('isCustomGasPriceSafe()', () => {
|
||
|
it('should return true for gas.customData.price 0x77359400', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x77359400' },
|
||
|
basicEstimates: { safeLow: 1 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return true for gas.customData.price null', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: null },
|
||
|
basicEstimates: { safeLow: 1 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return true gas.customData.price undefined', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: undefined },
|
||
|
basicEstimates: { safeLow: 1 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.safeLow undefined', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x77359400' },
|
||
|
basicEstimates: { safeLow: undefined },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('isCustomPriceExcessive()', () => {
|
||
|
it('should return false for gas.customData.price null', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: null },
|
||
|
basicEstimates: { fast: 150 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.fast undefined', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x77359400' },
|
||
|
basicEstimates: { fast: undefined },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.price 0x205d0bae00 (139)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x205d0bae00' },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.price 0x1bf08eb000 (120)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x1bf08eb000' },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.price 0x28bed01600 (175)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x28bed01600' },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return true gas.basicEstimates.price 0x30e4f9b400 (210)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
gas: {
|
||
|
customData: { price: '0x30e4f9b400' },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return false gas.basicEstimates.price 0x28bed01600 (175) (checkSend=true)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
metamask: {
|
||
|
send: {
|
||
|
gasPrice: '0x28bed0160',
|
||
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
customData: { price: null },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState, true)).toStrictEqual(false);
|
||
4 years ago
|
});
|
||
4 years ago
|
it('should return true gas.basicEstimates.price 0x30e4f9b400 (210) (checkSend=true)', () => {
|
||
4 years ago
|
const mockState = {
|
||
|
metamask: {
|
||
|
send: {
|
||
|
gasPrice: '0x30e4f9b400',
|
||
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
customData: { price: null },
|
||
|
basicEstimates: { fast: 139 },
|
||
|
},
|
||
|
};
|
||
4 years ago
|
expect(isCustomPriceExcessive(mockState, true)).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
|
||
4 years ago
|
describe('getCustomGasLimit()', () => {
|
||
|
it('should return gas.customData.limit', () => {
|
||
4 years ago
|
const mockState = { gas: { customData: { limit: 'mockLimit' } } };
|
||
4 years ago
|
expect(getCustomGasLimit(mockState)).toStrictEqual('mockLimit');
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('getRenderableBasicEstimateData()', () => {
|
||
6 years ago
|
const tests = [
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.01',
|
||
|
feeInPrimaryCurrency: '0.0000525 ETH',
|
||
6 years ago
|
priceInHexWei: '0x9502f900',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.000084 ETH',
|
||
|
feeInSecondaryCurrency: '$0.02',
|
||
|
priceInHexWei: '0xee6b2800',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.03',
|
||
|
feeInPrimaryCurrency: '0.000105 ETH',
|
||
6 years ago
|
priceInHexWei: '0x12a05f200',
|
||
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 255.71,
|
||
|
currentCurrency: 'usd',
|
||
6 years ago
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
6 years ago
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
blockTime: 14.16326530612245,
|
||
6 years ago
|
safeLow: 2.5,
|
||
6 years ago
|
safeLowWait: 6.6,
|
||
5 years ago
|
average: 4,
|
||
|
avgWait: 5.3,
|
||
6 years ago
|
fast: 5,
|
||
6 years ago
|
fastWait: 3.3,
|
||
6 years ago
|
fastest: 10,
|
||
6 years ago
|
fastestWait: 0.5,
|
||
6 years ago
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.27',
|
||
|
feeInPrimaryCurrency: '0.000105 ETH',
|
||
6 years ago
|
priceInHexWei: '0x12a05f200',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInPrimaryCurrency: '0.000147 ETH',
|
||
|
feeInSecondaryCurrency: '$0.38',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x1a13b8600',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.54',
|
||
|
feeInPrimaryCurrency: '0.00021 ETH',
|
||
6 years ago
|
priceInHexWei: '0x2540be400',
|
||
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
6 years ago
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
blockTime: 14.16326530612245,
|
||
|
safeLow: 5,
|
||
|
safeLowWait: 13.2,
|
||
5 years ago
|
average: 7,
|
||
|
avgWait: 10.1,
|
||
6 years ago
|
fast: 10,
|
||
|
fastWait: 6.6,
|
||
|
fastest: 20,
|
||
|
fastestWait: 1.0,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
feeInSecondaryCurrency: '',
|
||
|
feeInPrimaryCurrency: '0.000105 ETH',
|
||
|
priceInHexWei: '0x12a05f200',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.000147 ETH',
|
||
6 years ago
|
feeInSecondaryCurrency: '',
|
||
5 years ago
|
priceInHexWei: '0x1a13b8600',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
6 years ago
|
feeInSecondaryCurrency: '',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.00021 ETH',
|
||
|
priceInHexWei: '0x2540be400',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'rinkeby',
|
||
4 years ago
|
chainId: '0x4',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
blockTime: 14.16326530612245,
|
||
|
safeLow: 5,
|
||
|
safeLowWait: 13.2,
|
||
5 years ago
|
average: 7,
|
||
|
avgWait: 10.1,
|
||
6 years ago
|
fast: 10,
|
||
|
fastWait: 6.6,
|
||
|
fastest: 20,
|
||
|
fastestWait: 1.0,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.27',
|
||
|
feeInPrimaryCurrency: '0.000105 ETH',
|
||
|
priceInHexWei: '0x12a05f200',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.000147 ETH',
|
||
|
feeInSecondaryCurrency: '$0.38',
|
||
|
priceInHexWei: '0x1a13b8600',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.54',
|
||
|
feeInPrimaryCurrency: '0.00021 ETH',
|
||
|
priceInHexWei: '0x2540be400',
|
||
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: true,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'rinkeby',
|
||
4 years ago
|
chainId: '0x4',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
safeLow: 5,
|
||
5 years ago
|
average: 7,
|
||
6 years ago
|
fast: 10,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.27',
|
||
|
feeInPrimaryCurrency: '0.000105 ETH',
|
||
|
priceInHexWei: '0x12a05f200',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.000147 ETH',
|
||
|
feeInSecondaryCurrency: '$0.38',
|
||
|
priceInHexWei: '0x1a13b8600',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.54',
|
||
|
feeInPrimaryCurrency: '0.00021 ETH',
|
||
|
priceInHexWei: '0x2540be400',
|
||
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: true,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
6 years ago
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
6 years ago
|
safeLow: 5,
|
||
5 years ago
|
average: 7,
|
||
6 years ago
|
fast: 10,
|
||
6 years ago
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
];
|
||
4 years ago
|
it('should return renderable data about basic estimates', () => {
|
||
5 years ago
|
tests.forEach((test) => {
|
||
4 years ago
|
expect(
|
||
4 years ago
|
getRenderableBasicEstimateData(
|
||
|
test.mockState,
|
||
|
'0x5208',
|
||
|
test.useFastestButtons,
|
||
|
),
|
||
4 years ago
|
).toStrictEqual(test.expectedResult);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('getRenderableEstimateDataForSmallButtonsFromGWEI()', () => {
|
||
6 years ago
|
const tests = [
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
6 years ago
|
feeInSecondaryCurrency: '$0.13',
|
||
|
feeInPrimaryCurrency: '0.00052 ETH',
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
priceInHexWei: '0x5d21dba00',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$0.16',
|
||
|
feeInPrimaryCurrency: '0.00063 ETH',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x6fc23ac00',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$0.27',
|
||
|
feeInPrimaryCurrency: '0.00105 ETH',
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
5 years ago
|
priceInHexWei: '0xba43b7400',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 255.71,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
6 years ago
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
6 years ago
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
safeLow: 25,
|
||
5 years ago
|
average: 30,
|
||
6 years ago
|
fast: 50,
|
||
6 years ago
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
6 years ago
|
feeInSecondaryCurrency: '$2.68',
|
||
|
feeInPrimaryCurrency: '0.00105 ETH',
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
priceInHexWei: '0xba43b7400',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$4.03',
|
||
|
feeInPrimaryCurrency: '0.00157 ETH',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x1176592e00',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$5.37',
|
||
|
feeInPrimaryCurrency: '0.0021 ETH',
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
5 years ago
|
priceInHexWei: '0x174876e800',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
6 years ago
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
blockTime: 14.16326530612245,
|
||
|
safeLow: 50,
|
||
|
safeLowWait: 13.2,
|
||
5 years ago
|
average: 75,
|
||
|
avgWait: 9.6,
|
||
6 years ago
|
fast: 100,
|
||
|
fastWait: 6.6,
|
||
|
fastest: 200,
|
||
|
fastestWait: 1.0,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
|
feeInSecondaryCurrency: '',
|
||
|
feeInPrimaryCurrency: '0.00105 ETH',
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
priceInHexWei: '0xba43b7400',
|
||
|
},
|
||
|
{
|
||
|
feeInSecondaryCurrency: '',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.00157 ETH',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x1176592e00',
|
||
6 years ago
|
},
|
||
|
{
|
||
|
feeInSecondaryCurrency: '',
|
||
5 years ago
|
feeInPrimaryCurrency: '0.0021 ETH',
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
5 years ago
|
priceInHexWei: '0x174876e800',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: false,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'rinkeby',
|
||
4 years ago
|
chainId: '0x4',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
blockTime: 14.16326530612245,
|
||
|
safeLow: 50,
|
||
|
safeLowWait: 13.2,
|
||
5 years ago
|
average: 75,
|
||
|
avgWait: 9.6,
|
||
6 years ago
|
fast: 100,
|
||
|
fastWait: 6.6,
|
||
|
fastest: 200,
|
||
|
fastestWait: 1.0,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
|
feeInSecondaryCurrency: '$2.68',
|
||
|
feeInPrimaryCurrency: '0.00105 ETH',
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
priceInHexWei: '0xba43b7400',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$4.03',
|
||
|
feeInPrimaryCurrency: '0.00157 ETH',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x1176592e00',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$5.37',
|
||
|
feeInPrimaryCurrency: '0.0021 ETH',
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
5 years ago
|
priceInHexWei: '0x174876e800',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: true,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'rinkeby',
|
||
4 years ago
|
chainId: '0x4',
|
||
6 years ago
|
},
|
||
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
safeLow: 50,
|
||
5 years ago
|
average: 75,
|
||
6 years ago
|
fast: 100,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
expectedResult: [
|
||
|
{
|
||
|
feeInSecondaryCurrency: '$2.68',
|
||
|
feeInPrimaryCurrency: '0.00105 ETH',
|
||
5 years ago
|
gasEstimateType: 'SLOW',
|
||
6 years ago
|
priceInHexWei: '0xba43b7400',
|
||
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$4.03',
|
||
|
feeInPrimaryCurrency: '0.00157 ETH',
|
||
5 years ago
|
gasEstimateType: 'AVERAGE',
|
||
5 years ago
|
priceInHexWei: '0x1176592e00',
|
||
6 years ago
|
},
|
||
|
{
|
||
5 years ago
|
feeInSecondaryCurrency: '$5.37',
|
||
|
feeInPrimaryCurrency: '0.0021 ETH',
|
||
5 years ago
|
gasEstimateType: 'FAST',
|
||
5 years ago
|
priceInHexWei: '0x174876e800',
|
||
6 years ago
|
},
|
||
|
],
|
||
|
mockState: {
|
||
|
metamask: {
|
||
|
conversionRate: 2557.1,
|
||
|
currentCurrency: 'usd',
|
||
|
send: {
|
||
|
gasLimit: '0x5208',
|
||
|
},
|
||
|
preferences: {
|
||
|
showFiatInTestnets: true,
|
||
|
},
|
||
|
provider: {
|
||
|
type: 'mainnet',
|
||
4 years ago
|
chainId: '0x1',
|
||
6 years ago
|
},
|
||
6 years ago
|
},
|
||
|
gas: {
|
||
|
basicEstimates: {
|
||
|
safeLow: 50,
|
||
5 years ago
|
average: 75,
|
||
6 years ago
|
fast: 100,
|
||
6 years ago
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
];
|
||
4 years ago
|
it('should return renderable data about basic estimates appropriate for buttons with less info', () => {
|
||
5 years ago
|
tests.forEach((test) => {
|
||
4 years ago
|
expect(
|
||
6 years ago
|
getRenderableEstimateDataForSmallButtonsFromGWEI(test.mockState),
|
||
4 years ago
|
).toStrictEqual(test.expectedResult);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|