diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2019-05-15 04:22:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 04:22:54 +0800 |
commit | bf5b7f8e77684ce4a66d7e0301ed19d048a545f9 (patch) | |
tree | 9c68af7d6cb4b10410d5deeb33b9c9b61996cd02 /test | |
parent | 7dcc707a4329d69e9d4d7c6befbfd228ed7d714b (diff) | |
parent | 985f51a764560311e8aa5bb149e34b3c25b78c92 (diff) | |
download | tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar.gz tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar.bz2 tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar.lz tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar.xz tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.tar.zst tangerine-wallet-browser-bf5b7f8e77684ce4a66d7e0301ed19d048a545f9.zip |
Merge pull request #6599 from MetaMask/develop
Master Version Bump (v6.5.0)
Diffstat (limited to 'test')
23 files changed, 365 insertions, 156 deletions
diff --git a/test/e2e/beta/contract-test/contract.js b/test/e2e/beta/contract-test/contract.js index 65fb9377f..e1f886c58 100644 --- a/test/e2e/beta/contract-test/contract.js +++ b/test/e2e/beta/contract-test/contract.js @@ -37,8 +37,10 @@ web3.currentProvider.enable().then(() => { const createToken = document.getElementById('createToken') const transferTokens = document.getElementById('transferTokens') const approveTokens = document.getElementById('approveTokens') + const transferTokensWithoutGas = document.getElementById('transferTokensWithoutGas') + const approveTokensWithoutGas = document.getElementById('approveTokensWithoutGas') - deployButton.addEventListener('click', async function (event) { + deployButton.addEventListener('click', async function () { document.getElementById('contractStatus').innerHTML = 'Deploying' var piggybank = await piggybankContract.new( @@ -55,7 +57,7 @@ web3.currentProvider.enable().then(() => { document.getElementById('contractStatus').innerHTML = 'Deployed' - depositButton.addEventListener('click', function (event) { + depositButton.addEventListener('click', function () { document.getElementById('contractStatus').innerHTML = 'Deposit initiated' contract.deposit({ from: web3.eth.accounts[0], value: '0x3782dace9d900000' }, function (result) { console.log(result) @@ -63,7 +65,7 @@ web3.currentProvider.enable().then(() => { }) }) - withdrawButton.addEventListener('click', function (event) { + withdrawButton.addEventListener('click', function () { contract.withdraw('0xde0b6b3a7640000', { from: web3.eth.accounts[0] }, function (result) { console.log(result) document.getElementById('contractStatus').innerHTML = 'Withdrawn' @@ -75,7 +77,7 @@ web3.currentProvider.enable().then(() => { console.log(piggybank) }) - sendButton.addEventListener('click', function (event) { + sendButton.addEventListener('click', function () { web3.eth.sendTransaction({ from: web3.eth.accounts[0], to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970', @@ -88,7 +90,7 @@ web3.currentProvider.enable().then(() => { }) - createToken.addEventListener('click', async function (event) { + createToken.addEventListener('click', async function () { var _initialAmount = 100 var _tokenName = 'TST' var _decimalUnits = 0 @@ -124,7 +126,7 @@ web3.currentProvider.enable().then(() => { }) }) - approveTokens.addEventListener('click', function (event) { + approveTokens.addEventListener('click', function () { contract.approve('0x2f318C334780961FB129D2a6c30D0763d9a5C970', '7', { from: web3.eth.accounts[0], to: contract.address, @@ -135,6 +137,29 @@ web3.currentProvider.enable().then(() => { console.log(result) }) }) + + transferTokensWithoutGas.addEventListener('click', function (event) { + console.log(`event`, event) + contract.transfer('0x2f318C334780961FB129D2a6c30D0763d9a5C970', '7', { + from: web3.eth.accounts[0], + to: contract.address, + data: '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a', + gasPrice: '20000000000', + }, function (result) { + console.log('result', result) + }) + }) + + approveTokensWithoutGas.addEventListener('click', function () { + contract.approve('0x2f318C334780961FB129D2a6c30D0763d9a5C970', '7', { + from: web3.eth.accounts[0], + to: contract.address, + data: '0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005', + gasPrice: '20000000000', + }, function (result) { + console.log(result) + }) + }) } }) diff --git a/test/e2e/beta/contract-test/index.html b/test/e2e/beta/contract-test/index.html index 0d422ef20..6e134dc36 100644 --- a/test/e2e/beta/contract-test/index.html +++ b/test/e2e/beta/contract-test/index.html @@ -27,6 +27,8 @@ <button id="createToken">Create Token</button> <button id="transferTokens">Transfer Tokens</button> <button id="approveTokens">Approve Tokens</button> + <button id="transferTokensWithoutGas">Transfer Tokens Without Gas</button> + <button id="approveTokensWithoutGas">Approve Tokens Without Gas</button> </div> </div> diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 05ad84f24..06778ab99 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -812,10 +812,31 @@ describe('MetaMask', function () { await delay(regularDelayMs) const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) - await gasPriceInput.clear() + await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) await gasPriceInput.sendKeys('10') - await gasLimitInput.clear() + await delay(50) + await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) await gasLimitInput.sendKeys('60001') + await delay(50) + await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e')) + await delay(50) const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) await save.click() @@ -1175,7 +1196,7 @@ describe('MetaMask', function () { const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens')]`)) await transferTokens.click() - await closeAllWindowHandlesExcept(driver, extension) + await closeAllWindowHandlesExcept(driver, [extension, dapp]) await driver.switchTo().window(extension) await delay(regularDelayMs) @@ -1228,21 +1249,31 @@ describe('MetaMask', function () { await delay(regularDelayMs) const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) - await gasPriceInput.clear() - await delay(tinyDelayMs) + await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) await gasPriceInput.sendKeys('10') - await delay(tinyDelayMs) - await gasLimitInput.clear() - await delay(tinyDelayMs) + await delay(50) await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a')) - await gasLimitInput.sendKeys('60000') + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasLimitInput.sendKeys('60001') + await delay(50) await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e')) - - // Needed for different behaviour of input in different versions of firefox - const gasLimitInputValue = await gasLimitInput.getAttribute('value') - if (gasLimitInputValue === '600001') { - await gasLimitInput.sendKeys(Key.BACK_SPACE) - } + await delay(50) const save = await findElement(driver, By.css('.page-container__footer-button')) await save.click() @@ -1271,6 +1302,105 @@ describe('MetaMask', function () { }) }) + describe('Tranfers a custom token from dapp when no gas value is specified', () => { + it('transfers an already created token, without specifying gas', async () => { + const windowHandles = await driver.getAllWindowHandles() + const extension = windowHandles[0] + const dapp = await switchToWindowWithTitle(driver, 'E2E Test Dapp', windowHandles) + await closeAllWindowHandlesExcept(driver, [extension, dapp]) + await delay(regularDelayMs) + + await driver.switchTo().window(dapp) + + const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Transfer Tokens Without Gas')]`)) + await transferTokens.click() + + await closeAllWindowHandlesExcept(driver, [extension, dapp]) + await driver.switchTo().window(extension) + await delay(regularDelayMs) + + await driver.wait(async () => { + const pendingTxes = await findElements(driver, By.css('.transaction-list__pending-transactions .transaction-list-item')) + return pendingTxes.length === 1 + }, 10000) + + const [txListItem] = await findElements(driver, By.css('.transaction-list-item')) + const [txListValue] = await findElements(driver, By.css('.transaction-list-item__amount--primary')) + await driver.wait(until.elementTextMatches(txListValue, /-7\s*TST/)) + await txListItem.click() + await delay(regularDelayMs) + }) + + it('submits the transaction', async function () { + await delay(regularDelayMs) + const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) + await confirmButton.click() + await delay(regularDelayMs) + }) + + it('finds the transaction in the transactions list', async function () { + await driver.wait(async () => { + const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item')) + return confirmedTxes.length === 4 + }, 10000) + + const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) + await driver.wait(until.elementTextMatches(txValues[0], /-7\s*TST/)) + const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) + await driver.wait(until.elementTextMatches(txStatuses[0], /Sent Tokens/)) + }) + }) + + describe('Approves a custom token from dapp when no gas value is specified', () => { + it('approves an already created token', async () => { + const windowHandles = await driver.getAllWindowHandles() + const extension = windowHandles[0] + const dapp = await switchToWindowWithTitle(driver, 'E2E Test Dapp', windowHandles) + await closeAllWindowHandlesExcept(driver, [extension, dapp]) + await delay(regularDelayMs) + + await driver.switchTo().window(dapp) + await delay(tinyDelayMs) + + const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens Without Gas')]`)) + await transferTokens.click() + + await closeAllWindowHandlesExcept(driver, extension) + await driver.switchTo().window(extension) + await delay(regularDelayMs) + + await driver.wait(async () => { + const pendingTxes = await findElements(driver, By.css('.transaction-list__pending-transactions .transaction-list-item')) + return pendingTxes.length === 1 + }, 10000) + + const [txListItem] = await findElements(driver, By.css('.transaction-list-item')) + const [txListValue] = await findElements(driver, By.css('.transaction-list-item__amount--primary')) + await driver.wait(until.elementTextMatches(txListValue, /-7\s*TST/)) + await txListItem.click() + await delay(regularDelayMs) + }) + + it('submits the transaction', async function () { + await delay(regularDelayMs) + const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) + await confirmButton.click() + await delay(regularDelayMs) + }) + + it('finds the transaction in the transactions list', async function () { + await driver.wait(async () => { + const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item')) + return confirmedTxes.length === 5 + }, 10000) + + const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) + await driver.wait(until.elementTextMatches(txValues[0], /-7\s*TST/)) + const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) + await driver.wait(until.elementTextMatches(txStatuses[0], /Approve/)) + }) + }) + describe('Hide token', () => { it('hides the token when clicked', async () => { const [hideTokenEllipsis] = await findElements(driver, By.css('.token-list-item__ellipsis')) @@ -1341,11 +1471,14 @@ describe('MetaMask', function () { await customRpcButton.click() await delay(regularDelayMs) - const customRpcInput = await findElement(driver, By.css('input[placeholder="New RPC URL"]')) + await findElement(driver, By.css('.settings-page__sub-header-text')) + + const customRpcInputs = await findElements(driver, By.css('input[type="text"]')) + const customRpcInput = customRpcInputs[1] await customRpcInput.clear() await customRpcInput.sendKeys(customRpcUrl) - const customRpcSave = await findElement(driver, By.css('.settings-tab__rpc-save-button')) + const customRpcSave = await findElement(driver, By.css('.page-container__footer-button')) await customRpcSave.click() await delay(largeDelayMs * 2) }) diff --git a/test/integration/lib/confirm-sig-requests.js b/test/integration/lib/confirm-sig-requests.js index c3b0dfcff..699527609 100644 --- a/test/integration/lib/confirm-sig-requests.js +++ b/test/integration/lib/confirm-sig-requests.js @@ -15,16 +15,25 @@ QUnit.test('successful confirmation of sig requests', (assert) => { }) }) -async function runConfirmSigRequestsTest (assert, done) { +global.ethQuery = global.ethQuery || {} + +async function runConfirmSigRequestsTest (assert) { const selectState = await queryAsync($, 'select') selectState.val('confirm sig requests') reactTriggerChange(selectState[0]) + const realFetch = window.fetch.bind(window) global.fetch = (...args) => { - if (args[0].match(/chromeextensionmm/)) { + if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) + } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) }) + } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) }) + } else if (args[0].match(/chromeextensionmm/)) { return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) } - return window.fetch(...args) + return realFetch.fetch(...args) } const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid') diff --git a/test/integration/lib/currency-localization.js b/test/integration/lib/currency-localization.js index cd10efa30..24c3a1a2d 100644 --- a/test/integration/lib/currency-localization.js +++ b/test/integration/lib/currency-localization.js @@ -16,16 +16,23 @@ QUnit.test('renders localized currency', (assert) => { }) }) -async function runCurrencyLocalizationTest (assert, done) { +async function runCurrencyLocalizationTest (assert) { console.log('*** start runCurrencyLocalizationTest') const selectState = await queryAsync($, 'select') selectState.val('currency localization') + const realFetch = window.fetch.bind(window) global.fetch = (...args) => { - if (args[0].match(/chromeextensionmm/)) { + if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) + } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) }) + } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) }) + } else if (args[0].match(/chromeextensionmm/)) { return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) } - return window.fetch(...args) + return realFetch.fetch(...args) } await timeout(1000) diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js index 6a58611d1..78014feef 100644 --- a/test/integration/lib/send-new-ui.js +++ b/test/integration/lib/send-new-ui.js @@ -22,9 +22,10 @@ global.ethQuery = { global.ethereumProvider = {} -async function runSendFlowTest (assert, done) { +async function runSendFlowTest (assert) { const tempFetch = global.fetch + const realFetch = window.fetch.bind(window) global.fetch = (...args) => { if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) @@ -35,7 +36,7 @@ async function runSendFlowTest (assert, done) { } else if (args[0].match(/chromeextensionmm/)) { return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) } - return window.fetch(...args) + return realFetch.fetch(...args) } console.log('*** start runSendFlowTest') diff --git a/test/integration/lib/tx-list-items.js b/test/integration/lib/tx-list-items.js index c0056dd22..e4478614e 100644 --- a/test/integration/lib/tx-list-items.js +++ b/test/integration/lib/tx-list-items.js @@ -20,17 +20,24 @@ global.ethQuery.getTransactionCount = (_, cb) => { cb(null, '0x4') } -async function runTxListItemsTest (assert, done) { +async function runTxListItemsTest (assert) { console.log('*** start runTxListItemsTest') const selectState = await queryAsync($, 'select') selectState.val('tx list items') reactTriggerChange(selectState[0]) + const realFetch = window.fetch.bind(window) global.fetch = (...args) => { - if (args[0].match(/chromeextensionmm/)) { + if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) + } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) }) + } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') { + return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) }) + } else if (args[0].match(/chromeextensionmm/)) { return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) } - return window.fetch(...args) + return realFetch.fetch(...args) } const metamaskLogo = await queryAsync($, '.app-header__logo-container') diff --git a/test/lib/mock-encryptor.js b/test/lib/mock-encryptor.js index 852c536c2..23ab2404f 100644 --- a/test/lib/mock-encryptor.js +++ b/test/lib/mock-encryptor.js @@ -4,12 +4,12 @@ let cacheVal module.exports = { - encrypt (password, dataObj) { + encrypt (_, dataObj) { cacheVal = dataObj return Promise.resolve(mockHex) }, - decrypt (password, text) { + decrypt () { return Promise.resolve(cacheVal || {}) }, @@ -21,7 +21,7 @@ module.exports = { return this.decrypt(key, text) }, - keyFromPassword (password) { + keyFromPassword () { return Promise.resolve(mockKey) }, diff --git a/test/lib/util.js b/test/lib/util.js index 858565bb9..4c5d789d1 100644 --- a/test/lib/util.js +++ b/test/lib/util.js @@ -6,7 +6,7 @@ module.exports = { } function timeout (time) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { setTimeout(resolve, time || 1500) }) } diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js index 8c64d844f..f2f8f1d1c 100644 --- a/test/unit/actions/tx_test.js +++ b/test/unit/actions/tx_test.js @@ -33,8 +33,8 @@ describe('tx confirmation screen', function () { describe('cancelTx', function () { before(function (done) { actions._setBackgroundConnection({ - approveTransaction (txId, cb) { cb('An error!') }, - cancelTransaction (txId, cb) { cb() }, + approveTransaction (_, cb) { cb('An error!') }, + cancelTransaction (_, cb) { cb() }, clearSeedWordCache (cb) { cb() }, getState (cb) { cb() }, }) diff --git a/test/unit/app/controllers/blacklist-controller-test.js b/test/unit/app/controllers/blacklist-controller-test.js deleted file mode 100644 index 7a14c02cc..000000000 --- a/test/unit/app/controllers/blacklist-controller-test.js +++ /dev/null @@ -1,56 +0,0 @@ -const assert = require('assert') -const BlacklistController = require('../../../../app/scripts/controllers/blacklist') - -describe('blacklist controller', function () { - let blacklistController - - before(() => { - blacklistController = new BlacklistController() - }) - - describe('whitelistDomain', function () { - it('should add hostname to the runtime whitelist', function () { - blacklistController.whitelistDomain('foo.com') - assert.deepEqual(blacklistController.store.getState().whitelist, ['foo.com']) - - blacklistController.whitelistDomain('bar.com') - assert.deepEqual(blacklistController.store.getState().whitelist, ['bar.com', 'foo.com']) - }) - }) - - describe('checkForPhishing', function () { - it('should not flag whitelisted values', function () { - const result = blacklistController.checkForPhishing('www.metamask.io') - assert.equal(result, false) - }) - it('should flag explicit values', function () { - const result = blacklistController.checkForPhishing('metamask.com') - assert.equal(result, true) - }) - it('should flag levenshtein values', function () { - const result = blacklistController.checkForPhishing('metmask.io') - assert.equal(result, true) - }) - it('should not flag not-even-close values', function () { - const result = blacklistController.checkForPhishing('example.com') - assert.equal(result, false) - }) - it('should not flag the ropsten faucet domains', function () { - const result = blacklistController.checkForPhishing('faucet.metamask.io') - assert.equal(result, false) - }) - it('should not flag the mascara domain', function () { - const result = blacklistController.checkForPhishing('zero.metamask.io') - assert.equal(result, false) - }) - it('should not flag the mascara-faucet domain', function () { - const result = blacklistController.checkForPhishing('zero-faucet.metamask.io') - assert.equal(result, false) - }) - it('should not flag whitelisted domain', function () { - blacklistController.whitelistDomain('metamask.com') - const result = blacklistController.checkForPhishing('metamask.com') - assert.equal(result, false) - }) - }) -}) diff --git a/test/unit/app/controllers/currency-controller-test.js b/test/unit/app/controllers/currency-controller-test.js index 7c4644d9f..8b6fbb719 100644 --- a/test/unit/app/controllers/currency-controller-test.js +++ b/test/unit/app/controllers/currency-controller-test.js @@ -59,7 +59,7 @@ describe('currency-controller', function () { var promise = new Promise( - function (resolve, reject) { + function (resolve) { currencyController.setCurrentCurrency('jpy') currencyController.updateConversionRate().then(function () { resolve() diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index 1ed6a95fb..a56b8adbd 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -49,7 +49,7 @@ describe('MetaMaskController', function () { showUnapprovedTx: noop, showUnconfirmedMessage: noop, encryptor: { - encrypt: function (password, object) { + encrypt: function (_, object) { this.object = object return Promise.resolve('mock-encrypted') }, @@ -144,7 +144,7 @@ describe('MetaMaskController', function () { sandbox.stub(metamaskController, 'getBalance') metamaskController.getBalance.callsFake(() => { return Promise.resolve('0x0') }) - await metamaskController.createNewVaultAndRestore(password, TEST_SEED.slice(0, -1)).catch((e) => null) + await metamaskController.createNewVaultAndRestore(password, TEST_SEED.slice(0, -1)).catch(() => null) await metamaskController.createNewVaultAndRestore(password, TEST_SEED) assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice) @@ -207,7 +207,7 @@ describe('MetaMaskController', function () { const accounts = {} const balance = '0x14ced5122ce0a000' const ethQuery = new EthQuery() - sinon.stub(ethQuery, 'getBalance').callsFake((account, callback) => { + sinon.stub(ethQuery, 'getBalance').callsFake((_, callback) => { callback(undefined, balance) }) @@ -295,7 +295,7 @@ describe('MetaMaskController', function () { it('should add the Trezor Hardware keyring', async function () { sinon.spy(metamaskController.keyringController, 'addNewKeyring') - await metamaskController.connectHardware('trezor', 0).catch((e) => null) + await metamaskController.connectHardware('trezor', 0).catch(() => null) const keyrings = await metamaskController.keyringController.getKeyringsByType( 'Trezor Hardware' ) @@ -305,7 +305,7 @@ describe('MetaMaskController', function () { it('should add the Ledger Hardware keyring', async function () { sinon.spy(metamaskController.keyringController, 'addNewKeyring') - await metamaskController.connectHardware('ledger', 0).catch((e) => null) + await metamaskController.connectHardware('ledger', 0).catch(() => null) const keyrings = await metamaskController.keyringController.getKeyringsByType( 'Ledger Hardware' ) @@ -325,7 +325,7 @@ describe('MetaMaskController', function () { }) it('should be locked by default', async function () { - await metamaskController.connectHardware('trezor', 0).catch((e) => null) + await metamaskController.connectHardware('trezor', 0).catch(() => null) const status = await metamaskController.checkHardwareStatus('trezor') assert.equal(status, false) }) @@ -341,7 +341,7 @@ describe('MetaMaskController', function () { }) it('should wipe all the keyring info', async function () { - await metamaskController.connectHardware('trezor', 0).catch((e) => null) + await metamaskController.connectHardware('trezor', 0).catch(() => null) await metamaskController.forgetDevice('trezor') const keyrings = await metamaskController.keyringController.getKeyringsByType( 'Trezor Hardware' @@ -376,7 +376,7 @@ describe('MetaMaskController', function () { sinon.spy(metamaskController.preferencesController, 'setAddresses') sinon.spy(metamaskController.preferencesController, 'setSelectedAddress') sinon.spy(metamaskController.preferencesController, 'setAccountLabel') - await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`).catch((e) => null) + await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`).catch(() => null) await metamaskController.unlockHardwareWalletAccount(accountToUnlock, 'trezor', `m/44/0'/0'`) }) @@ -464,7 +464,7 @@ describe('MetaMaskController', function () { depositAddress = '3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc' depositType = 'ETH' - shapeShiftTxList = metamaskController.shapeshiftController.store.getState().shapeShiftTxList + shapeShiftTxList = metamaskController.shapeshiftController.state.shapeShiftTxList }) it('creates a shapeshift tx', async function () { @@ -752,12 +752,11 @@ describe('MetaMaskController', function () { }) it('sets up phishing stream for untrusted communication ', async () => { - await metamaskController.blacklistController.updatePhishingList() - console.log(blacklistJSON.blacklist.includes(phishingUrl)) + await metamaskController.phishingController.updatePhishingLists() const { promise, resolve } = deferredPromise() - streamTest = createThoughStream((chunk, enc, cb) => { + streamTest = createThoughStream((chunk, _, cb) => { if (chunk.name !== 'phishing') return cb() assert.equal(chunk.data.hostname, phishingUrl) resolve() @@ -777,7 +776,7 @@ describe('MetaMaskController', function () { }) it('sets up controller dnode api for trusted communication', function (done) { - streamTest = createThoughStream((chunk, enc, cb) => { + streamTest = createThoughStream((chunk, _, cb) => { assert.equal(chunk.name, 'controller') cb() done() diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 558597ae7..81b152f3d 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -527,14 +527,14 @@ describe('preferences controller', function () { it('should add custom RPC url to state', function () { preferencesController.addToFrequentRpcList('rpc_url', 1) preferencesController.addToFrequentRpcList('http://localhost:8545', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '', rpcPrefs: {} }]) preferencesController.addToFrequentRpcList('rpc_url', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '', rpcPrefs: {} }]) }) it('should remove custom RPC url from state', function () { preferencesController.addToFrequentRpcList('rpc_url', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '', rpcPrefs: {} }]) preferencesController.removeFromFrequentRpcList('other_rpc_url') preferencesController.removeFromFrequentRpcList('http://localhost:8545') preferencesController.removeFromFrequentRpcList('rpc_url') diff --git a/test/unit/app/controllers/transactions/pending-tx-test.js b/test/unit/app/controllers/transactions/pending-tx-test.js index 2988bf61f..1c5f59f5a 100644 --- a/test/unit/app/controllers/transactions/pending-tx-test.js +++ b/test/unit/app/controllers/transactions/pending-tx-test.js @@ -100,7 +100,7 @@ describe('PendingTransactionTracker', function () { describe('#_checkPendingTx', function () { it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) { - pendingTxTracker.once('tx:failed', (txId, err) => { + pendingTxTracker.once('tx:failed', (txId) => { assert(txId, txMetaNoHash.id, 'should pass txId') done() }) @@ -128,7 +128,7 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then((txCompletedList) => done()) + .then(() => done()) .catch(done) pendingTxTracker.updatePendingTxs() @@ -152,7 +152,7 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then((txCompletedList) => done()) + .then(() => done()) .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) @@ -178,7 +178,7 @@ describe('PendingTransactionTracker', function () { throw new Error(knownErrors.pop()) } Promise.all(txList.map((tx) => tx.processed)) - .then((txCompletedList) => done()) + .then(() => done()) .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) @@ -194,9 +194,9 @@ describe('PendingTransactionTracker', function () { }) pendingTxTracker.getPendingTransactions = () => txList - pendingTxTracker._resubmitTx = async (tx) => { throw new TypeError('im some real error') } + pendingTxTracker._resubmitTx = async () => { throw new TypeError('im some real error') } Promise.all(txList.map((tx) => tx.processed)) - .then((txCompletedList) => done()) + .then(() => done()) .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 9000cd364..8ff409207 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -8,6 +8,13 @@ const TransactionController = require('../../../../../app/scripts/controllers/tr const { TRANSACTION_TYPE_RETRY, } = require('../../../../../app/scripts/controllers/transactions/enums') +const { + TOKEN_METHOD_APPROVE, + TOKEN_METHOD_TRANSFER, + SEND_ETHER_ACTION_KEY, + DEPLOY_CONTRACT_ACTION_KEY, + CONTRACT_INTERACTION_KEY, +} = require('../../../../../ui/app/helpers/constants/transactions.js') const { createTestProviderTools, getTestAccounts } = require('../../../../stub/provider') const noop = () => true @@ -537,6 +544,86 @@ describe('Transaction Controller', function () { }) }) + describe('#_determineTransactionCategory', function () { + it('should return a simple send transactionCategory when to is truthy but data is falsey', async function () { + const result = await txController._determineTransactionCategory({ + to: '0xabc', + data: '', + }) + assert.deepEqual(result, { transactionCategory: SEND_ETHER_ACTION_KEY, getCodeResponse: undefined }) + }) + + it('should return a token transfer transactionCategory when data is for the respective method call', async function () { + const result = await txController._determineTransactionCategory({ + to: '0xabc', + data: '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a', + }) + assert.deepEqual(result, { transactionCategory: TOKEN_METHOD_TRANSFER, getCodeResponse: undefined }) + }) + + it('should return a token approve transactionCategory when data is for the respective method call', async function () { + const result = await txController._determineTransactionCategory({ + to: '0xabc', + data: '0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005', + }) + assert.deepEqual(result, { transactionCategory: TOKEN_METHOD_APPROVE, getCodeResponse: undefined }) + }) + + it('should return a contract deployment transactionCategory when to is falsey and there is data', async function () { + const result = await txController._determineTransactionCategory({ + to: '', + data: '0xabd', + }) + assert.deepEqual(result, { transactionCategory: DEPLOY_CONTRACT_ACTION_KEY, getCodeResponse: undefined }) + }) + + it('should return a simple send transactionCategory with a 0x getCodeResponse when there is data and but the to address is not a contract address', async function () { + const result = await txController._determineTransactionCategory({ + to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9', + data: '0xabd', + }) + assert.deepEqual(result, { transactionCategory: SEND_ETHER_ACTION_KEY, getCodeResponse: '0x' }) + }) + + it('should return a simple send transactionCategory with a null getCodeResponse when to is truthy and there is data and but getCode returns an error', async function () { + const result = await txController._determineTransactionCategory({ + to: '0xabc', + data: '0xabd', + }) + assert.deepEqual(result, { transactionCategory: SEND_ETHER_ACTION_KEY, getCodeResponse: null }) + }) + + it('should return a contract interaction transactionCategory with the correct getCodeResponse when to is truthy and there is data and it is not a token transaction', async function () { + const _providerResultStub = { + // 1 gwei + eth_gasPrice: '0x0de0b6b3a7640000', + // by default, all accounts are external accounts (not contracts) + eth_getCode: '0xa', + } + const _provider = createTestProviderTools({ scaffold: _providerResultStub }).provider + const _fromAccount = getTestAccounts()[0] + const _blockTrackerStub = new EventEmitter() + _blockTrackerStub.getCurrentBlock = noop + _blockTrackerStub.getLatestBlock = noop + const _txController = new TransactionController({ + provider: _provider, + getGasPrice: function () { return '0xee6b2800' }, + networkStore: new ObservableStore(currentNetworkId), + txHistoryLimit: 10, + blockTracker: _blockTrackerStub, + signTransaction: (ethTx) => new Promise((resolve) => { + ethTx.sign(_fromAccount.key) + resolve() + }), + }) + const result = await _txController._determineTransactionCategory({ + to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9', + data: 'abd', + }) + assert.deepEqual(result, { transactionCategory: CONTRACT_INTERACTION_KEY, getCodeResponse: '0x0a' }) + }) + }) + describe('#getPendingTransactions', function () { beforeEach(function () { txController.txStateManager._saveTxList([ diff --git a/test/unit/app/controllers/transactions/tx-gas-util-test.js b/test/unit/app/controllers/transactions/tx-gas-util-test.js index 31defd6ed..f92d95507 100644 --- a/test/unit/app/controllers/transactions/tx-gas-util-test.js +++ b/test/unit/app/controllers/transactions/tx-gas-util-test.js @@ -11,7 +11,7 @@ describe('txUtils', function () { before(function () { txUtils = new TxUtils(new Proxy({}, { - get: (obj, name) => { + get: () => { return () => {} }, })) diff --git a/test/unit/app/controllers/transactions/tx-state-history-helper-test.js b/test/unit/app/controllers/transactions/tx-state-history-helper-test.js index fba0e7fda..328c2ac6f 100644 --- a/test/unit/app/controllers/transactions/tx-state-history-helper-test.js +++ b/test/unit/app/controllers/transactions/tx-state-history-helper-test.js @@ -29,7 +29,7 @@ describe('Transaction state history helper', function () { describe('#migrateFromSnapshotsToDiffs', function () { it('migrates history to diffs and can recover original values', function () { - testVault.data.TransactionController.transactions.forEach((tx, index) => { + testVault.data.TransactionController.transactions.forEach((tx) => { const newHistory = txStateHistoryHelper.migrateFromSnapshotsToDiffs(tx.history) newHistory.forEach((newEntry, index) => { if (index === 0) { diff --git a/test/unit/app/controllers/transactions/tx-state-manager-test.js b/test/unit/app/controllers/transactions/tx-state-manager-test.js index 88bdaa60e..4ccade2aa 100644 --- a/test/unit/app/controllers/transactions/tx-state-manager-test.js +++ b/test/unit/app/controllers/transactions/tx-state-manager-test.js @@ -55,7 +55,7 @@ describe('TransactionStateManager', function () { it('should emit a rejected event to signal the exciton of callback', (done) => { const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} } txStateManager.addTx(tx) - const noop = function (err, txId) { + const noop = function (err) { if (err) { console.log('Error: ', err) } diff --git a/test/unit/app/edge-encryptor-test.js b/test/unit/app/edge-encryptor-test.js index 1a6255b36..52817cd09 100644 --- a/test/unit/app/edge-encryptor-test.js +++ b/test/unit/app/edge-encryptor-test.js @@ -83,7 +83,7 @@ describe('EdgeEncryptor', function () { edgeEncryptor.encrypt(password, data) .then(function (encryptedData) { edgeEncryptor.decrypt('wrong password', encryptedData) - .then(function (decryptedData) { + .then(function () { assert.fail('could decrypt with wrong password') done() }) diff --git a/test/unit/migrations/migrator-test.js b/test/unit/migrations/migrator-test.js index a9374dff1..693c5830d 100644 --- a/test/unit/migrations/migrator-test.js +++ b/test/unit/migrations/migrator-test.js @@ -61,7 +61,7 @@ describe('Migrator', () => { const migrator = new Migrator({ migrations: [{ version: 1, migrate: async () => { throw new Error('test') } } ] }) migrator.on('error', () => done()) migrator.migrateData({ meta: {version: 0} }) - .then((migratedData) => { + .then(() => { }).catch(done) }) diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index 86c3f8aff..34dd6a39b 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -44,7 +44,7 @@ describe('Actions', () => { showUnapprovedTx: noop, showUnconfirmedMessage: noop, encryptor: { - encrypt: function (password, object) { + encrypt: function (_, object) { this.object = object return Promise.resolve('mock-encrypted') }, @@ -103,7 +103,7 @@ describe('Actions', () => { submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((password, callback) => { + submitPasswordSpy.callsFake((_, callback) => { callback(new Error('error in submitPassword')) }) @@ -235,7 +235,7 @@ describe('Actions', () => { createNewVaultAndRestoreSpy = sinon.stub(background, 'createNewVaultAndRestore') - createNewVaultAndRestoreSpy.callsFake((password, seed, callback) => { + createNewVaultAndRestoreSpy.callsFake((_, __, callback) => { callback(new Error('error')) }) @@ -279,7 +279,7 @@ describe('Actions', () => { ] createNewVaultAndKeychainSpy = sinon.stub(background, 'createNewVaultAndKeychain') - createNewVaultAndKeychainSpy.callsFake((password, callback) => { + createNewVaultAndKeychainSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -342,7 +342,7 @@ describe('Actions', () => { ] submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((password, callback) => { + submitPasswordSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -414,7 +414,7 @@ describe('Actions', () => { it('displays warning error message when submitPassword in background errors', () => { submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((password, callback) => { + submitPasswordSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -483,7 +483,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, ] removeAccountSpy = sinon.stub(background, 'removeAccount') - removeAccountSpy.callsFake((address, callback) => { + removeAccountSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -522,7 +522,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, ] - addNewKeyringSpy.callsFake((type, opts, callback) => { + addNewKeyringSpy.callsFake((_, __, callback) => { callback(new Error('error')) }) @@ -611,7 +611,7 @@ describe('Actions', () => { ] importAccountWithStrategySpy = sinon.stub(background, 'importAccountWithStrategy') - importAccountWithStrategySpy.callsFake((strategy, args, callback) => { + importAccountWithStrategySpy.callsFake((_, __, callback) => { callback(new Error('error')) }) @@ -668,7 +668,7 @@ describe('Actions', () => { { type: 'HIDE_LOADING_INDICATION' }, { type: 'DISPLAY_WARNING', value: 'error' }, ] - setCurrentCurrencySpy.callsFake((currencyCode, callback) => { + setCurrentCurrencySpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -720,7 +720,7 @@ describe('Actions', () => { ] signMessageSpy = sinon.stub(background, 'signMessage') - signMessageSpy.callsFake((msgData, callback) => { + signMessageSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -775,7 +775,7 @@ describe('Actions', () => { ] signPersonalMessageSpy = sinon.stub(background, 'signPersonalMessage') - signPersonalMessageSpy.callsFake((msgData, callback) => { + signPersonalMessageSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -812,7 +812,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, { type: 'SHOW_CONF_TX_PAGE', transForward: true, id: undefined }, ] - sendTransactionSpy.callsFake((txData, callback) => { + sendTransactionSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -906,7 +906,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, ] - setSelectedAddressSpy.callsFake((address, callback) => { + setSelectedAddressSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -941,7 +941,7 @@ describe('Actions', () => { { type: 'HIDE_LOADING_INDICATION' }, { type: 'DISPLAY_WARNING', value: 'error' }, ] - setSelectedAddressSpy.callsFake((address, callback) => { + setSelectedAddressSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -980,7 +980,7 @@ describe('Actions', () => { { type: 'UPDATE_TOKENS', newTokens: undefined }, ] - addTokenSpy.callsFake((address, symbol, decimals, image, callback) => { + addTokenSpy.callsFake((_, __, ___, ____, callback) => { callback(new Error('error')) }) @@ -1020,7 +1020,7 @@ describe('Actions', () => { { type: 'UPDATE_TOKENS', newTokens: undefined }, ] - removeTokenSpy.callsFake((address, callback) => { + removeTokenSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1054,7 +1054,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'Had a problem changing networks!' }, ] - setProviderTypeSpy.callsFake((type, callback) => { + setProviderTypeSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1087,7 +1087,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'Had a problem changing networks!' }, ] - setRpcTargetSpy.callsFake((newRpc, chainId, ticker, nickname, callback) => { + setRpcTargetSpy.callsFake((_, __, ___, ____, callback) => { callback(new Error('error')) }) @@ -1134,7 +1134,7 @@ describe('Actions', () => { exportAccountSpy = sinon.spy(background, 'exportAccount') return store.dispatch(actions.exportAccount(password, '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc')) - .then((result) => { + .then(() => { assert(submitPasswordSpy.calledOnce) assert(exportAccountSpy.calledOnce) assert.deepEqual(store.getActions(), expectedActions) @@ -1150,7 +1150,7 @@ describe('Actions', () => { ] submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((password, callback) => { + submitPasswordSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1169,7 +1169,7 @@ describe('Actions', () => { ] exportAccountSpy = sinon.stub(background, 'exportAccount') - exportAccountSpy.callsFake((address, callback) => { + exportAccountSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1196,7 +1196,6 @@ describe('Actions', () => { describe('#pairUpdate', () => { beforeEach(() => { - nock('https://shapeshift.io') .defaultReplyHeaders({ 'access-control-allow-origin': '*' }) .get('/marketinfo/btc_eth') @@ -1206,10 +1205,6 @@ describe('Actions', () => { .defaultReplyHeaders({ 'access-control-allow-origin': '*' }) .get('/coins') .reply(200) - }) - - afterEach(() => { - nock.restore() }) it('', () => { @@ -1251,7 +1246,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, ] - setFeatureFlagSpy.callsFake((feature, activated, callback) => { + setFeatureFlagSpy.callsFake((_, __, callback) => { callback(new Error('error')) }) @@ -1305,7 +1300,7 @@ describe('Actions', () => { ] getTransactionCountSpy = sinon.stub(global.ethQuery, 'getTransactionCount') - getTransactionCountSpy.callsFake((address, callback) => { + getTransactionCountSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1343,7 +1338,7 @@ describe('Actions', () => { { type: 'SET_USE_BLOCKIE', value: undefined }, ] - setUseBlockieSpy.callsFake((val, callback) => { + setUseBlockieSpy.callsFake((_, callback) => { callback(new Error('error')) }) @@ -1390,7 +1385,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, ] setCurrentLocaleSpy = sinon.stub(background, 'setCurrentLocale') - setCurrentLocaleSpy.callsFake((key, callback) => { + setCurrentLocaleSpy.callsFake((_, callback) => { callback(new Error('error')) }) diff --git a/test/web3/web3.js b/test/web3/web3.js index 5c2de078d..0f7a4c3cd 100644 --- a/test/web3/web3.js +++ b/test/web3/web3.js @@ -12,7 +12,7 @@ web3.currentProvider.enable().then(() => { Object.keys(methodGroup).forEach(methodKey => { const methodButton = document.getElementById(methodKey) - methodButton.addEventListener('click', function (event) { + methodButton.addEventListener('click', function () { window.ethereum.sendAsync({ method: methodKey, |