1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Fix/handle safe low undefined (#10561)

* fix: handle safeLow undefined

fixes #10558

* fix: add tests for isCustomGasPriceSafe selector
This commit is contained in:
Shane 2021-03-02 14:19:56 -08:00 committed by GitHub
parent 1ed75b45f7
commit d44c4d3747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -64,7 +64,7 @@ export function isCustomPriceSafe(state) {
return true; return true;
} }
if (safeLow === null) { if (!safeLow) {
return false; return false;
} }

View File

@ -6,6 +6,7 @@ const {
getCustomGasPrice, getCustomGasPrice,
getRenderableBasicEstimateData, getRenderableBasicEstimateData,
getRenderableEstimateDataForSmallButtonsFromGWEI, getRenderableEstimateDataForSmallButtonsFromGWEI,
isCustomPriceSafe,
} = proxyquire('../custom-gas', {}); } = proxyquire('../custom-gas', {});
describe('custom-gas selectors', function () { describe('custom-gas selectors', function () {
@ -15,6 +16,44 @@ describe('custom-gas selectors', function () {
assert.strictEqual(getCustomGasPrice(mockState), 'mockPrice'); assert.strictEqual(getCustomGasPrice(mockState), 'mockPrice');
}); });
}); });
describe('isCustomGasPriceSafe()', function () {
it('should return true for gas.customData.price 0x77359400', function () {
const mockState = {
gas: {
customData: { price: '0x77359400' },
basicEstimates: { safeLow: 1 },
},
};
assert.strictEqual(isCustomPriceSafe(mockState), true);
});
it('should return true for gas.customData.price null', function () {
const mockState = {
gas: {
customData: { price: null },
basicEstimates: { safeLow: 1 },
},
};
assert.strictEqual(isCustomPriceSafe(mockState), true);
});
it('should return true gas.customData.price undefined', function () {
const mockState = {
gas: {
customData: { price: undefined },
basicEstimates: { safeLow: 1 },
},
};
assert.strictEqual(isCustomPriceSafe(mockState), true);
});
it('should return false gas.basicEstimates.safeLow undefined', function () {
const mockState = {
gas: {
customData: { price: '0x77359400' },
basicEstimates: { safeLow: undefined },
},
};
assert.strictEqual(isCustomPriceSafe(mockState), false);
});
});
describe('getCustomGasLimit()', function () { describe('getCustomGasLimit()', function () {
it('should return gas.customData.limit', function () { it('should return gas.customData.limit', function () {