From 1bad3fa25782a322859df8942abf39b08777f13d Mon Sep 17 00:00:00 2001 From: Paul Bouchon Date: Fri, 27 Apr 2018 10:42:02 -0400 Subject: Allow transactions with 0-gwei gas price (#4073) * Allow transactions with 0-gwei gas price * Add tests to verify tx with 0 gas fee * Conditionally use CurrencyInput in CurrencyDisplay --- test/integration/lib/send-new-ui.js | 59 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'test/integration/lib') diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js index 09a074750..3da3f4f95 100644 --- a/test/integration/lib/send-new-ui.js +++ b/test/integration/lib/send-new-ui.js @@ -23,6 +23,37 @@ global.ethQuery = { global.ethereumProvider = {} +async function customizeGas (assert, price, limit, ethFee, usdFee) { + const sendGasOpenCustomizeModalButton = await queryAsync($, '.sliders-icon-container') + sendGasOpenCustomizeModalButton[0].click() + + const customizeGasModal = await queryAsync($, '.send-v2__customize-gas') + assert.ok(customizeGasModal[0], 'should render the customize gas modal') + + const customizeGasPriceInput = (await queryAsync($, '.send-v2__gas-modal-card')).first().find('input') + customizeGasPriceInput.val(price) + reactTriggerChange(customizeGasPriceInput[0]) + const customizeGasLimitInput = (await queryAsync($, '.send-v2__gas-modal-card')).last().find('input') + customizeGasLimitInput.val(limit) + reactTriggerChange(customizeGasLimitInput[0]) + + const customizeGasSaveButton = await queryAsync($, '.send-v2__customize-gas__save') + customizeGasSaveButton[0].click() + const sendGasField = await queryAsync($, '.send-v2__gas-fee-display') + + assert.equal( + (await findAsync(sendGasField, '.currency-display__input-wrapper > input')).val(), + ethFee, + 'send gas field should show customized gas total' + ) + + assert.equal( + (await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent, + usdFee, + 'send gas field should show customized gas total converted to USD' + ) +} + async function runSendFlowTest(assert, done) { console.log('*** start runSendFlowTest') const selectState = await queryAsync($, 'select') @@ -95,32 +126,8 @@ async function runSendFlowTest(assert, done) { 'send gas field should show estimated gas total converted to USD' ) - const sendGasOpenCustomizeModalButton = await queryAsync($, '.sliders-icon-container') - sendGasOpenCustomizeModalButton[0].click() - - const customizeGasModal = await queryAsync($, '.send-v2__customize-gas') - assert.ok(customizeGasModal[0], 'should render the customize gas modal') - - const customizeGasPriceInput = (await queryAsync($, '.send-v2__gas-modal-card')).first().find('input') - customizeGasPriceInput.val(50) - reactTriggerChange(customizeGasPriceInput[0]) - const customizeGasLimitInput = (await queryAsync($, '.send-v2__gas-modal-card')).last().find('input') - customizeGasLimitInput.val(60000) - reactTriggerChange(customizeGasLimitInput[0]) - - const customizeGasSaveButton = await queryAsync($, '.send-v2__customize-gas__save') - customizeGasSaveButton[0].click() - - assert.equal( - (await findAsync(sendGasField, '.currency-display__input-wrapper > input')).val(), - '0.003', - 'send gas field should show customized gas total' - ) - assert.equal( - (await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent, - '$3.60 USD', - 'send gas field should show customized gas total converted to USD' - ) + await customizeGas(assert, 0, 21000, '0', '$0.00 USD') + await customizeGas(assert, 500, 60000, '0.003', '$3.60 USD') const sendButton = await queryAsync($, 'button.btn-primary--lg.page-container__footer-button') assert.equal(sendButton[0].textContent, 'Next', 'next button rendered') -- cgit v1.2.3