From 4d88e1cf862c3ae174780cd888d7703685db23e7 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Wed, 31 Jul 2019 17:47:11 -0230 Subject: Enable indent linting via ESLint (#6936) * Enable indent linting via ESLint * yarn run lint:fix --- test/e2e/contract-test/contract.js | 4 +- test/e2e/helpers.js | 2 +- test/e2e/metamask-responsive-ui.spec.js | 168 +++++++------- test/e2e/web3.spec.js | 246 ++++++++++----------- test/unit/app/controllers/detect-tokens-test.js | 16 +- .../controllers/transactions/pending-tx-test.js | 90 ++++---- .../recipient-blacklist-checker-test.js | 4 +- .../controllers/transactions/tx-controller-test.js | 100 ++++----- .../transactions/tx-state-manager-test.js | 12 +- .../app/controllers/transactions/tx-utils-test.js | 2 +- test/unit/app/edge-encryptor-test.js | 32 +-- test/unit/localhostState.js | 10 +- test/unit/migrations/021-test.js | 12 +- test/unit/migrations/022-test.js | 22 +- test/unit/migrations/023-test.js | 44 ++-- test/unit/migrations/024-test.js | 24 +- test/unit/migrations/025-test.js | 24 +- test/unit/migrations/029-test.js | 24 +- test/unit/migrations/030-test.js | 16 +- test/unit/migrations/031-test.js | 8 +- test/unit/migrations/migrations-test.js | 154 ++++++------- test/unit/migrations/migrator-test.js | 22 +- test/unit/migrations/template-test.js | 8 +- test/unit/ui/app/actions.spec.js | 2 +- test/web3/schema.js | 2 +- test/web3/web3.js | 4 +- 26 files changed, 526 insertions(+), 526 deletions(-) (limited to 'test') diff --git a/test/e2e/contract-test/contract.js b/test/e2e/contract-test/contract.js index 3f22b442a..9fe5c21b1 100644 --- a/test/e2e/contract-test/contract.js +++ b/test/e2e/contract-test/contract.js @@ -72,7 +72,7 @@ web3.currentProvider.enable().then(() => { }) }) } - }) + }) console.log(piggybank) }) @@ -161,7 +161,7 @@ web3.currentProvider.enable().then(() => { }) }) } - }) + }) }) }) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 9b2029dde..30b8d13f6 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -162,6 +162,6 @@ async function switchToWindowWithUrlThatMatches (driver, regexp, windowHandles) if (windowUrl.match(regexp)) { return firstHandle } else { - return await switchToWindowWithUrlThatMatches(driver, regexp, windowHandles.slice(1)) + return await switchToWindowWithUrlThatMatches(driver, regexp, windowHandles.slice(1)) } } diff --git a/test/e2e/metamask-responsive-ui.spec.js b/test/e2e/metamask-responsive-ui.spec.js index 720cac333..90661e387 100644 --- a/test/e2e/metamask-responsive-ui.spec.js +++ b/test/e2e/metamask-responsive-ui.spec.js @@ -109,110 +109,110 @@ describe('MetaMask', function () { }) describe('Going through the first time flow', () => { - it('clicks the continue button on the welcome screen', async () => { - await findElement(driver, By.css('.welcome-page__header')) - const welcomeScreenBtn = await findElement(driver, By.css('.first-time-flow__button')) - welcomeScreenBtn.click() - await delay(largeDelayMs) - }) + it('clicks the continue button on the welcome screen', async () => { + await findElement(driver, By.css('.welcome-page__header')) + const welcomeScreenBtn = await findElement(driver, By.css('.first-time-flow__button')) + welcomeScreenBtn.click() + await delay(largeDelayMs) + }) - it('clicks the "Create New Wallet" option', async () => { - const customRpcButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Create a Wallet')]`)) - customRpcButton.click() - await delay(largeDelayMs) - }) + it('clicks the "Create New Wallet" option', async () => { + const customRpcButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Create a Wallet')]`)) + customRpcButton.click() + await delay(largeDelayMs) + }) - it('clicks the "I agree" option on the metametrics opt-in screen', async () => { - const optOutButton = await findElement(driver, By.css('.btn-primary')) - optOutButton.click() - await delay(largeDelayMs) - }) + it('clicks the "I agree" option on the metametrics opt-in screen', async () => { + const optOutButton = await findElement(driver, By.css('.btn-primary')) + optOutButton.click() + await delay(largeDelayMs) + }) + + it('accepts a secure password', async () => { + const passwordBox = await findElement(driver, By.css('.first-time-flow__form #create-password')) + const passwordBoxConfirm = await findElement(driver, By.css('.first-time-flow__form #confirm-password')) + const button = await findElement(driver, By.css('.first-time-flow__form button')) - it('accepts a secure password', async () => { - const passwordBox = await findElement(driver, By.css('.first-time-flow__form #create-password')) - const passwordBoxConfirm = await findElement(driver, By.css('.first-time-flow__form #confirm-password')) - const button = await findElement(driver, By.css('.first-time-flow__form button')) + await passwordBox.sendKeys('correct horse battery staple') + await passwordBoxConfirm.sendKeys('correct horse battery staple') - await passwordBox.sendKeys('correct horse battery staple') - await passwordBoxConfirm.sendKeys('correct horse battery staple') + const tosCheckBox = await findElement(driver, By.css('.first-time-flow__checkbox')) + await tosCheckBox.click() - const tosCheckBox = await findElement(driver, By.css('.first-time-flow__checkbox')) - await tosCheckBox.click() + await button.click() + await delay(regularDelayMs) + }) - await button.click() - await delay(regularDelayMs) - }) + let seedPhrase - let seedPhrase + it('reveals the seed phrase', async () => { + const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button') + await driver.wait(until.elementLocated(byRevealButton, 10000)) + const revealSeedPhraseButton = await findElement(driver, byRevealButton, 10000) + await revealSeedPhraseButton.click() + await delay(regularDelayMs) - it('reveals the seed phrase', async () => { - const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button') - await driver.wait(until.elementLocated(byRevealButton, 10000)) - const revealSeedPhraseButton = await findElement(driver, byRevealButton, 10000) - await revealSeedPhraseButton.click() - await delay(regularDelayMs) + seedPhrase = await driver.findElement(By.css('.reveal-seed-phrase__secret-words')).getText() + assert.equal(seedPhrase.split(' ').length, 12) + await delay(regularDelayMs) - seedPhrase = await driver.findElement(By.css('.reveal-seed-phrase__secret-words')).getText() - assert.equal(seedPhrase.split(' ').length, 12) - await delay(regularDelayMs) + const nextScreen = await findElement(driver, By.css('button.first-time-flow__button')) + await nextScreen.click() + await delay(regularDelayMs) + }) - const nextScreen = await findElement(driver, By.css('button.first-time-flow__button')) - await nextScreen.click() - await delay(regularDelayMs) - }) + async function clickWordAndWait (word) { + const xpath = `//div[contains(@class, 'confirm-seed-phrase__seed-word--shuffled') and not(contains(@class, 'confirm-seed-phrase__seed-word--selected')) and contains(text(), '${word}')]` + const word0 = await findElement(driver, By.xpath(xpath), 10000) - async function clickWordAndWait (word) { - const xpath = `//div[contains(@class, 'confirm-seed-phrase__seed-word--shuffled') and not(contains(@class, 'confirm-seed-phrase__seed-word--selected')) and contains(text(), '${word}')]` - const word0 = await findElement(driver, By.xpath(xpath), 10000) + await word0.click() + await delay(tinyDelayMs) + } - await word0.click() - await delay(tinyDelayMs) - } + async function retypeSeedPhrase (words, wasReloaded, count = 0) { + try { + if (wasReloaded) { + const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button') + await driver.wait(until.elementLocated(byRevealButton, 10000)) + const revealSeedPhraseButton = await findElement(driver, byRevealButton, 10000) + await revealSeedPhraseButton.click() + await delay(regularDelayMs) + + const nextScreen = await findElement(driver, By.css('button.first-time-flow__button')) + await nextScreen.click() + await delay(regularDelayMs) + } - async function retypeSeedPhrase (words, wasReloaded, count = 0) { - try { - if (wasReloaded) { - const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button') - await driver.wait(until.elementLocated(byRevealButton, 10000)) - const revealSeedPhraseButton = await findElement(driver, byRevealButton, 10000) - await revealSeedPhraseButton.click() - await delay(regularDelayMs) - - const nextScreen = await findElement(driver, By.css('button.first-time-flow__button')) - await nextScreen.click() - await delay(regularDelayMs) - } - - for (let i = 0; i < 12; i++) { - await clickWordAndWait(words[i]) - } - } catch (e) { - if (count > 2) { - throw e - } else { - await loadExtension(driver, extensionId) - await retypeSeedPhrase(words, true, count + 1) - } + for (let i = 0; i < 12; i++) { + await clickWordAndWait(words[i]) + } + } catch (e) { + if (count > 2) { + throw e + } else { + await loadExtension(driver, extensionId) + await retypeSeedPhrase(words, true, count + 1) } } + } - it('can retype the seed phrase', async () => { - const words = seedPhrase.split(' ') + it('can retype the seed phrase', async () => { + const words = seedPhrase.split(' ') - await retypeSeedPhrase(words) + await retypeSeedPhrase(words) - const confirm = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) - await confirm.click() - await delay(regularDelayMs) - }) + const confirm = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) + await confirm.click() + await delay(regularDelayMs) + }) - it('clicks through the success screen', async () => { - await findElement(driver, By.xpath(`//div[contains(text(), 'Congratulations')]`)) - const doneButton = await findElement(driver, By.css('button.first-time-flow__button')) - await doneButton.click() - await delay(regularDelayMs) - }) + it('clicks through the success screen', async () => { + await findElement(driver, By.xpath(`//div[contains(text(), 'Congratulations')]`)) + const doneButton = await findElement(driver, By.css('button.first-time-flow__button')) + await doneButton.click() + await delay(regularDelayMs) }) + }) describe('Show account information', () => { it('show account details dropdown menu', async () => { diff --git a/test/e2e/web3.spec.js b/test/e2e/web3.spec.js index e5be24672..36a1c0509 100644 --- a/test/e2e/web3.spec.js +++ b/test/e2e/web3.spec.js @@ -34,9 +34,9 @@ describe('Using MetaMask with an existing account', function () { const button = async (x) => { const buttoncheck = x await buttoncheck.click() - await delay(largeDelayMs) - const [results] = await findElements(driver, By.css('#results')) - const resulttext = await results.getText() + await delay(largeDelayMs) + const [results] = await findElements(driver, By.css('#results')) + const resulttext = await results.getText() var parsedData = JSON.parse(resulttext) return (parsedData) @@ -169,197 +169,197 @@ describe('Using MetaMask with an existing account', function () { }) - describe('opens dapp', () => { + describe('opens dapp', () => { - it('switches to mainnet', async () => { - const networkDropdown = await findElement(driver, By.css('.network-name')) - await networkDropdown.click() - await delay(regularDelayMs) + it('switches to mainnet', async () => { + const networkDropdown = await findElement(driver, By.css('.network-name')) + await networkDropdown.click() + await delay(regularDelayMs) - const [mainnet] = await findElements(driver, By.xpath(`//span[contains(text(), 'Main Ethereum Network')]`)) - await mainnet.click() - await delay(largeDelayMs * 2) - }) + const [mainnet] = await findElements(driver, By.xpath(`//span[contains(text(), 'Main Ethereum Network')]`)) + await mainnet.click() + await delay(largeDelayMs * 2) + }) - it('', async () => { - await openNewPage(driver, 'http://127.0.0.1:8080/') - await delay(regularDelayMs) + it('', async () => { + await openNewPage(driver, 'http://127.0.0.1:8080/') + await delay(regularDelayMs) - await waitUntilXWindowHandles(driver, 3) - const windowHandles = await driver.getAllWindowHandles() + await waitUntilXWindowHandles(driver, 3) + const windowHandles = await driver.getAllWindowHandles() - const extension = windowHandles[0] - const popup = await switchToWindowWithTitle(driver, 'MetaMask Notification', windowHandles) - const dapp = windowHandles.find(handle => handle !== extension && handle !== popup) + const extension = windowHandles[0] + const popup = await switchToWindowWithTitle(driver, 'MetaMask Notification', windowHandles) + const dapp = windowHandles.find(handle => handle !== extension && handle !== popup) - await delay(regularDelayMs) - const approveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Connect')]`)) - await approveButton.click() + await delay(regularDelayMs) + const approveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Connect')]`)) + await approveButton.click() - await driver.switchTo().window(dapp) - await delay(regularDelayMs) + await driver.switchTo().window(dapp) + await delay(regularDelayMs) - }) }) + }) - describe('testing web3 methods', async () => { + describe('testing web3 methods', async () => { - it('testing hexa methods', async () => { + it('testing hexa methods', async () => { - var List = await driver.findElements(By.className('hexaNumberMethods')) + var List = await driver.findElements(By.className('hexaNumberMethods')) - for (let i = 0; i < List.length; i++) { - try { + for (let i = 0; i < List.length; i++) { + try { - var parsedData = await button(List[i]) - console.log(parsedData) - var result = parseInt(parsedData.result, 16) + var parsedData = await button(List[i]) + console.log(parsedData) + var result = parseInt(parsedData.result, 16) - assert.equal((typeof result === 'number'), true) - await delay(regularDelayMs) - } catch (err) { - console.log(err) - assert(false) + assert.equal((typeof result === 'number'), true) + await delay(regularDelayMs) + } catch (err) { + console.log(err) + assert(false) - } } - }) + } + }) - it('testing booleanMethods', async () => { + it('testing booleanMethods', async () => { - var List = await driver.findElements(By.className('booleanMethods')) + var List = await driver.findElements(By.className('booleanMethods')) - for (let i = 0; i < List.length; i++) { - try { + for (let i = 0; i < List.length; i++) { + try { - var parsedData = await button(List[i]) - console.log(parsedData) - var result = parsedData.result + var parsedData = await button(List[i]) + console.log(parsedData) + var result = parsedData.result - assert.equal(result, false) - await delay(regularDelayMs) - } catch (err) { - console.log(err) - assert(false) + assert.equal(result, false) + await delay(regularDelayMs) + } catch (err) { + console.log(err) + assert(false) - } } + } - }) + }) - it('testing transactionMethods', async () => { + it('testing transactionMethods', async () => { - var List = await driver.findElements(By.className('transactionMethods')) + var List = await driver.findElements(By.className('transactionMethods')) - for (let i = 0; i < List.length; i++) { - try { + for (let i = 0; i < List.length; i++) { + try { - var parsedData = await button(List[i]) + var parsedData = await button(List[i]) - console.log(parsedData.result.blockHash) + console.log(parsedData.result.blockHash) - var result = [] - result.push(parseInt(parsedData.result.blockHash, 16)) - result.push(parseInt(parsedData.result.blockNumber, 16)) - result.push(parseInt(parsedData.result.gas, 16)) - result.push(parseInt(parsedData.result.gasPrice, 16)) - result.push(parseInt(parsedData.result.hash, 16)) - result.push(parseInt(parsedData.result.input, 16)) - result.push(parseInt(parsedData.result.nonce, 16)) - result.push(parseInt(parsedData.result.r, 16)) - result.push(parseInt(parsedData.result.s, 16)) - result.push(parseInt(parsedData.result.v, 16)) - result.push(parseInt(parsedData.result.to, 16)) - result.push(parseInt(parsedData.result.value, 16)) + var result = [] + result.push(parseInt(parsedData.result.blockHash, 16)) + result.push(parseInt(parsedData.result.blockNumber, 16)) + result.push(parseInt(parsedData.result.gas, 16)) + result.push(parseInt(parsedData.result.gasPrice, 16)) + result.push(parseInt(parsedData.result.hash, 16)) + result.push(parseInt(parsedData.result.input, 16)) + result.push(parseInt(parsedData.result.nonce, 16)) + result.push(parseInt(parsedData.result.r, 16)) + result.push(parseInt(parsedData.result.s, 16)) + result.push(parseInt(parsedData.result.v, 16)) + result.push(parseInt(parsedData.result.to, 16)) + result.push(parseInt(parsedData.result.value, 16)) - result.forEach((value) => { - assert.equal((typeof value === 'number'), true) - }) + result.forEach((value) => { + assert.equal((typeof value === 'number'), true) + }) - } catch (err) { + } catch (err) { - console.log(err) - assert(false) + console.log(err) + assert(false) - } } + } - }) + }) - it('testing blockMethods', async () => { + it('testing blockMethods', async () => { - var List = await driver.findElements(By.className('blockMethods')) + var List = await driver.findElements(By.className('blockMethods')) - for (let i = 0; i < List.length; i++) { - try { + for (let i = 0; i < List.length; i++) { + try { - var parsedData = await button(List[i]) - console.log(JSON.stringify(parsedData) + i) + var parsedData = await button(List[i]) + console.log(JSON.stringify(parsedData) + i) - console.log(parsedData.result.parentHash) + console.log(parsedData.result.parentHash) - var result = parseInt(parsedData.result.parentHash, 16) + var result = parseInt(parsedData.result.parentHash, 16) - assert.equal((typeof result === 'number'), true) - await delay(regularDelayMs) - } catch (err) { + assert.equal((typeof result === 'number'), true) + await delay(regularDelayMs) + } catch (err) { - console.log(err) - assert(false) + console.log(err) + assert(false) - } } - }) + } + }) - it('testing methods', async () => { + it('testing methods', async () => { - var List = await driver.findElements(By.className('methods')) - var parsedData - var result + var List = await driver.findElements(By.className('methods')) + var parsedData + var result - for (let i = 0; i < List.length; i++) { - try { + for (let i = 0; i < List.length; i++) { + try { - if (i === 2) { + if (i === 2) { - parsedData = await button(List[i]) - console.log(parsedData.result.blockHash) + parsedData = await button(List[i]) + console.log(parsedData.result.blockHash) - result = parseInt(parsedData.result.blockHash, 16) + result = parseInt(parsedData.result.blockHash, 16) - assert.equal((typeof result === 'number' || (result === 0)), true) - await delay(regularDelayMs) - } else { - parsedData = await button(List[i]) - console.log(parsedData.result) + assert.equal((typeof result === 'number' || (result === 0)), true) + await delay(regularDelayMs) + } else { + parsedData = await button(List[i]) + console.log(parsedData.result) - result = parseInt(parsedData.result, 16) + result = parseInt(parsedData.result, 16) - assert.equal((typeof result === 'number' || (result === 0)), true) - await delay(regularDelayMs) - } + assert.equal((typeof result === 'number' || (result === 0)), true) + await delay(regularDelayMs) + } - } catch (err) { + } catch (err) { - console.log(err) - assert(false) + console.log(err) + assert(false) - } } - }) + } + }) - }) + }) - }) +}) diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js index 2acc53e92..8f18406f4 100644 --- a/test/unit/app/controllers/detect-tokens-test.js +++ b/test/unit/app/controllers/detect-tokens-test.js @@ -71,8 +71,8 @@ describe('DetectTokensController', () => { controller.isUnlocked = true var stub = sandbox.stub(controller, 'detectTokenBalance') - .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true) - .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true) + .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true) + .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true) await controller.detectNewTokens() sandbox.assert.notCalled(stub) @@ -84,14 +84,14 @@ describe('DetectTokensController', () => { controller.isUnlocked = true sandbox.stub(controller, 'detectTokenBalance') - .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4') - .returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)) - .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388') - .returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18)) + .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4') + .returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)) + .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388') + .returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18)) await controller.detectNewTokens() assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'}, - {address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}]) + {address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}]) }) it('should not detect same token while in main network', async () => { @@ -108,7 +108,7 @@ describe('DetectTokensController', () => { await controller.detectNewTokens() assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'}, - {address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}]) + {address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}]) }) it('should trigger detect new tokens when change address', async () => { diff --git a/test/unit/app/controllers/transactions/pending-tx-test.js b/test/unit/app/controllers/transactions/pending-tx-test.js index b37ac2766..e1de5731b 100644 --- a/test/unit/app/controllers/transactions/pending-tx-test.js +++ b/test/unit/app/controllers/transactions/pending-tx-test.js @@ -7,7 +7,7 @@ const sinon = require('sinon') describe('PendingTransactionTracker', function () { let pendingTxTracker, txMeta, txMetaNoHash, providerResultStub, - provider, txMeta3, txList, knownErrors + provider, txMeta3, txList, knownErrors this.timeout(10000) beforeEach(function () { @@ -80,7 +80,7 @@ describe('PendingTransactionTracker', function () { }, { count: 1 })[0] stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions') - .returns(txGen.txs) + .returns(txGen.txs) // THE EXPECTATION const spy = sinon.spy() @@ -107,18 +107,18 @@ describe('PendingTransactionTracker', function () { }) it('should emit tx:dropped with the txMetas id only after the second call', function (done) { - txMeta = { - id: 1, - hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb', - status: 'submitted', - txParams: { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - nonce: '0x1', - value: '0xfffff', - }, - history: [{}], - rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d', - } + txMeta = { + id: 1, + hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb', + status: 'submitted', + txParams: { + from: '0x1678a085c290ebd122dc42cba69373b5953b831d', + nonce: '0x1', + value: '0xfffff', + }, + history: [{}], + rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d', + } providerResultStub['eth_getTransactionCount'] = '0x02' providerResultStub['eth_getTransactionByHash'] = {} @@ -159,8 +159,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.updatePendingTxs() }) @@ -169,8 +169,8 @@ describe('PendingTransactionTracker', function () { describe('#resubmitPendingTxs', function () { const blockNumberStub = '0x0' beforeEach(function () { - const txMeta2 = txMeta3 = txMeta - txList = [txMeta, txMeta2, txMeta3].map((tx) => { + const txMeta2 = txMeta3 = txMeta + txList = [txMeta, txMeta2, txMeta3].map((tx) => { tx.processed = new Promise((resolve) => { tx.resolve = resolve }) return tx }) @@ -183,8 +183,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) it('should not emit \'tx:failed\' if the txMeta throws a known txError', function (done) { @@ -209,8 +209,8 @@ describe('PendingTransactionTracker', function () { throw new Error(knownErrors.pop()) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) @@ -227,8 +227,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async () => { throw new TypeError('im some real error') } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) @@ -264,11 +264,11 @@ describe('PendingTransactionTracker', function () { // Stubbing out current account state: // Adding the fake tx: pendingTxTracker._resubmitTx(txMeta) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction') }) @@ -278,11 +278,11 @@ describe('PendingTransactionTracker', function () { const mockLatestBlockNumber = '0x5' pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 0, 'Should NOT call publish transaction') }) @@ -292,11 +292,11 @@ describe('PendingTransactionTracker', function () { const mockLatestBlockNumber = '0x11' pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction') }) @@ -382,11 +382,11 @@ describe('PendingTransactionTracker', function () { value: '0xfffff', }, }) - .then((taken) => { - assert.ok(!taken) - done() - }) - .catch(done) + .then((taken) => { + assert.ok(!taken) + done() + }) + .catch(done) }) it('should return true if nonce has been taken', function (done) { @@ -400,7 +400,7 @@ describe('PendingTransactionTracker', function () { assert.ok(taken) done() }) - .catch(done) + .catch(done) }) }) }) diff --git a/test/unit/app/controllers/transactions/recipient-blacklist-checker-test.js b/test/unit/app/controllers/transactions/recipient-blacklist-checker-test.js index d3e47c67e..1d6a0eb08 100644 --- a/test/unit/app/controllers/transactions/recipient-blacklist-checker-test.js +++ b/test/unit/app/controllers/transactions/recipient-blacklist-checker-test.js @@ -31,8 +31,8 @@ describe('Recipient Blacklist Checker', function () { const networks = [ROPSTEN_CODE, RINKEYBY_CODE, KOVAN_CODE, GOERLI_CODE] for (const networkId in networks) { publicAccounts.forEach((account) => { - recipientBlackListChecker.checkAccount(networkId, account) - callCount++ + recipientBlackListChecker.checkAccount(networkId, account) + callCount++ }) } assert.equal(callCount, 40) diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 8ff409207..9072dc684 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -129,13 +129,13 @@ describe('Transaction Controller', function () { stub = sinon.stub(txController, 'addUnapprovedTransaction').callsFake(() => { txController.emit('newUnapprovedTx', txMeta) return Promise.resolve(txController.txStateManager.addTx(txMeta)) - }) + }) - afterEach(function () { - txController.txStateManager._saveTxList([]) - stub.restore() + afterEach(function () { + txController.txStateManager._saveTxList([]) + stub.restore() + }) }) - }) it('should resolve when finished and status is submitted and resolve with the hash', function (done) { txController.once('newUnapprovedTx', (txMetaFromEmit) => { @@ -146,11 +146,11 @@ describe('Transaction Controller', function () { }) txController.newUnapprovedTransaction(txParams) - .then((hash) => { - assert(hash, 'newUnapprovedTransaction needs to return the hash') - done() - }) - .catch(done) + .then((hash) => { + assert(hash, 'newUnapprovedTransaction needs to return the hash') + done() + }) + .catch(done) }) it('should reject when finished and status is rejected', function (done) { @@ -161,10 +161,10 @@ describe('Transaction Controller', function () { }) txController.newUnapprovedTransaction(txParams) - .catch((err) => { - if (err.message === 'MetaMask Tx Signature: User denied transaction signature.') done() - else done(err) - }) + .catch((err) => { + if (err.message === 'MetaMask Tx Signature: User denied transaction signature.') done() + else done(err) + }) }) }) @@ -182,17 +182,17 @@ describe('Transaction Controller', function () { it('should add an unapproved transaction and return a valid txMeta', function (done) { txController.addUnapprovedTransaction({ from: selectedAddress }) - .then((txMeta) => { - assert(('id' in txMeta), 'should have a id') - assert(('time' in txMeta), 'should have a time stamp') - assert(('metamaskNetworkId' in txMeta), 'should have a metamaskNetworkId') - assert(('txParams' in txMeta), 'should have a txParams') - assert(('history' in txMeta), 'should have a history') - - const memTxMeta = txController.txStateManager.getTx(txMeta.id) - assert.deepEqual(txMeta, memTxMeta, `txMeta should be stored in txController after adding it\n expected: ${txMeta} \n got: ${memTxMeta}`) - done() - }).catch(done) + .then((txMeta) => { + assert(('id' in txMeta), 'should have a id') + assert(('time' in txMeta), 'should have a time stamp') + assert(('metamaskNetworkId' in txMeta), 'should have a metamaskNetworkId') + assert(('txParams' in txMeta), 'should have a txParams') + assert(('history' in txMeta), 'should have a history') + + const memTxMeta = txController.txStateManager.getTx(txMeta.id) + assert.deepEqual(txMeta, memTxMeta, `txMeta should be stored in txController after adding it\n expected: ${txMeta} \n got: ${memTxMeta}`) + done() + }).catch(done) }) it('should emit newUnapprovedTx event and pass txMeta as the first argument', function (done) { @@ -202,16 +202,16 @@ describe('Transaction Controller', function () { done() }) txController.addUnapprovedTransaction({ from: selectedAddress }) - .catch(done) + .catch(done) }) it('should fail if recipient is public', function (done) { txController.networkStore = new ObservableStore(1) txController.addUnapprovedTransaction({ from: selectedAddress, to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' }) - .catch((err) => { - if (err.message === 'Recipient is a public account') done() - else done(err) - }) + .catch((err) => { + if (err.message === 'Recipient is a public account') done() + else done(err) + }) }) it('should fail if the from address isn\'t the selected address', function (done) { @@ -232,16 +232,16 @@ describe('Transaction Controller', function () { done() }) txController.addUnapprovedTransaction({ from: selectedAddress, to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' }) - .catch(done) + .catch(done) }) it('should fail if netId is loading', function (done) { txController.networkStore = new ObservableStore('loading') txController.addUnapprovedTransaction({ from: selectedAddress, to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' }) - .catch((err) => { - if (err.message === 'MetaMask is having trouble connecting to the network') done() - else done(err) - }) + .catch((err) => { + if (err.message === 'MetaMask is having trouble connecting to the network') done() + else done(err) + }) }) }) @@ -284,11 +284,11 @@ describe('Transaction Controller', function () { })) }) Promise.all(listeners) - .then((returnValues) => { - assert.deepEqual(returnValues.pop(), txMeta, 'last event 1:unapproved should return txMeta') - done() - }) - .catch(done) + .then((returnValues) => { + assert.deepEqual(returnValues.pop(), txMeta, 'last event 1:unapproved should return txMeta') + done() + }) + .catch(done) txController.addTx(txMeta) }) }) @@ -511,16 +511,16 @@ describe('Transaction Controller', function () { { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, ]) txController.retryTransaction(1) - .then((txMeta) => { - assert.equal(txMeta.txParams.gasPrice, '0x10642ac00', 'gasPrice should have a %10 gasPrice bump') - assert.equal(txMeta.txParams.nonce, txParams.nonce, 'nonce should be the same') - assert.equal(txMeta.txParams.from, txParams.from, 'from should be the same') - assert.equal(txMeta.txParams.to, txParams.to, 'to should be the same') - assert.equal(txMeta.txParams.data, txParams.data, 'data should be the same') - assert.ok(('lastGasPrice' in txMeta), 'should have the key `lastGasPrice`') - assert.equal(txController.txStateManager.getTxList().length, 2) - done() - }).catch(done) + .then((txMeta) => { + assert.equal(txMeta.txParams.gasPrice, '0x10642ac00', 'gasPrice should have a %10 gasPrice bump') + assert.equal(txMeta.txParams.nonce, txParams.nonce, 'nonce should be the same') + assert.equal(txMeta.txParams.from, txParams.from, 'from should be the same') + assert.equal(txMeta.txParams.to, txParams.to, 'to should be the same') + assert.equal(txMeta.txParams.data, txParams.data, 'data should be the same') + assert.ok(('lastGasPrice' in txMeta), 'should have the key `lastGasPrice`') + assert.equal(txController.txStateManager.getTxList().length, 2) + done() + }).catch(done) }) }) 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 72dbbc4a1..48343bcd7 100644 --- a/test/unit/app/controllers/transactions/tx-state-manager-test.js +++ b/test/unit/app/controllers/transactions/tx-state-manager-test.js @@ -43,7 +43,7 @@ describe('TransactionStateManager', function () { }) describe('#setTxStatusRejected', function () { - it('sets the tx status to rejected and removes it from history', function () { + it('sets the tx status to rejected and removes it from history', function () { const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} } txStateManager.addTx(tx) txStateManager.setTxStatusRejected(1) @@ -56,11 +56,11 @@ describe('TransactionStateManager', function () { const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} } txStateManager.addTx(tx) const noop = function (err) { - if (err) { - console.log('Error: ', err) - } - assert(true, 'event listener has been triggered and noop executed') - done() + if (err) { + console.log('Error: ', err) + } + assert(true, 'event listener has been triggered and noop executed') + done() } txStateManager.on('1:rejected', noop) txStateManager.setTxStatusRejected(1) diff --git a/test/unit/app/controllers/transactions/tx-utils-test.js b/test/unit/app/controllers/transactions/tx-utils-test.js index 029fab4d5..65c8d35b0 100644 --- a/test/unit/app/controllers/transactions/tx-utils-test.js +++ b/test/unit/app/controllers/transactions/tx-utils-test.js @@ -93,6 +93,6 @@ describe('txUtils', function () { // should run txParams.from = '0x1678a085c290ebd122dc42cba69373b5953b831d' txUtils.validateFrom(txParams) - }) + }) }) }) diff --git a/test/unit/app/edge-encryptor-test.js b/test/unit/app/edge-encryptor-test.js index 52817cd09..ad873e351 100644 --- a/test/unit/app/edge-encryptor-test.js +++ b/test/unit/app/edge-encryptor-test.js @@ -65,13 +65,13 @@ describe('EdgeEncryptor', function () { edgeEncryptor.encrypt(password, data) .then(function (encryptedData) { edgeEncryptor.decrypt(password, encryptedData) - .then(function (decryptedData) { - assert.equal(decryptedData, data) - done() - }) - .catch(function (err) { - done(err) - }) + .then(function (decryptedData) { + assert.equal(decryptedData, data) + done() + }) + .catch(function (err) { + done(err) + }) }) .catch(function (err) { done(err) @@ -83,15 +83,15 @@ describe('EdgeEncryptor', function () { edgeEncryptor.encrypt(password, data) .then(function (encryptedData) { edgeEncryptor.decrypt('wrong password', encryptedData) - .then(function () { - assert.fail('could decrypt with wrong password') - done() - }) - .catch(function (err) { - assert.ok(err instanceof Error) - assert.equal(err.message, 'Incorrect password') - done() - }) + .then(function () { + assert.fail('could decrypt with wrong password') + done() + }) + .catch(function (err) { + assert.ok(err instanceof Error) + assert.equal(err.message, 'Incorrect password') + done() + }) }) .catch(function (err) { done(err) diff --git a/test/unit/localhostState.js b/test/unit/localhostState.js index f9fa157d7..71adbb859 100644 --- a/test/unit/localhostState.js +++ b/test/unit/localhostState.js @@ -10,12 +10,12 @@ */ const initialState = { config: {}, - NetworkController: { - provider: { - type: 'rpc', - rpcTarget: 'http://localhost:8545', - }, + NetworkController: { + provider: { + type: 'rpc', + rpcTarget: 'http://localhost:8545', }, + }, } module.exports = initialState diff --git a/test/unit/migrations/021-test.js b/test/unit/migrations/021-test.js index 458e9b4b5..d46b2a835 100644 --- a/test/unit/migrations/021-test.js +++ b/test/unit/migrations/021-test.js @@ -6,11 +6,11 @@ const migration21 = require('../../../app/scripts/migrations/021') describe('wallet2 is migrated successfully with out the BlacklistController', () => { it('should delete BlacklistController key', (done) => { migration21.migrate(wallet2) - .then((migratedData) => { - assert.equal(migratedData.meta.version, 21) - assert(!migratedData.data.BlacklistController) - assert(!migratedData.data.RecentBlocks) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 21) + assert(!migratedData.data.BlacklistController) + assert(!migratedData.data.RecentBlocks) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/022-test.js b/test/unit/migrations/022-test.js index f8ee00e38..f7dd35b08 100644 --- a/test/unit/migrations/022-test.js +++ b/test/unit/migrations/022-test.js @@ -17,16 +17,16 @@ const storage = { describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => { it('should add submittedTime key on the txMeta if appropriate', (done) => { migration22.migrate(storage) - .then((migratedData) => { - const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions - assert.equal(migratedData.meta.version, 22) - // should have written a submitted time - assert(txMeta1.submittedTime) - // should not have written a submitted time because it already has one - assert.equal(txMeta2.submittedTime, properTime) - // should not have written a submitted time - assert(!txMeta3.submittedTime) - done() - }).catch(done) + .then((migratedData) => { + const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions + assert.equal(migratedData.meta.version, 22) + // should have written a submitted time + assert(txMeta1.submittedTime) + // should not have written a submitted time because it already has one + assert.equal(txMeta2.submittedTime, properTime) + // should not have written a submitted time + assert(!txMeta3.submittedTime) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/023-test.js b/test/unit/migrations/023-test.js index 7da94448d..1b47dea92 100644 --- a/test/unit/migrations/023-test.js +++ b/test/unit/migrations/023-test.js @@ -57,41 +57,41 @@ storage.data.TransactionController.transactions = transactions describe('storage is migrated successfully and the proper transactions are remove from state', () => { it('should remove transactions that are unneeded', (done) => { migration23.migrate(storage) - .then((migratedData) => { - let leftoverNonDeletableTxCount = 0 - const migratedTransactions = migratedData.data.TransactionController.transactions - migratedTransactions.forEach((tx) => { - if (!deletableTxStates.find((s) => s === tx.status)) { - leftoverNonDeletableTxCount++ - } - }) - assert.equal(leftoverNonDeletableTxCount, nonDeletableCount, 'migration shouldnt delete transactions we want to keep') - assert((migratedTransactions.length >= 40), `should be equal or greater to 40 if they are non deletable states got ${migratedTransactions.length} transactions`) - done() - }).catch(done) + .then((migratedData) => { + let leftoverNonDeletableTxCount = 0 + const migratedTransactions = migratedData.data.TransactionController.transactions + migratedTransactions.forEach((tx) => { + if (!deletableTxStates.find((s) => s === tx.status)) { + leftoverNonDeletableTxCount++ + } + }) + assert.equal(leftoverNonDeletableTxCount, nonDeletableCount, 'migration shouldnt delete transactions we want to keep') + assert((migratedTransactions.length >= 40), `should be equal or greater to 40 if they are non deletable states got ${migratedTransactions.length} transactions`) + done() + }).catch(done) }) it('should not remove any transactions because 40 is the expectable limit', (done) => { storage.meta.version = 22 storage.data.TransactionController.transactions = transactions40 migration23.migrate(storage) - .then((migratedData) => { - const migratedTransactions = migratedData.data.TransactionController.transactions + .then((migratedData) => { + const migratedTransactions = migratedData.data.TransactionController.transactions - assert.equal(migratedTransactions.length, 40, 'migration shouldnt delete when at limit') - done() - }).catch(done) + assert.equal(migratedTransactions.length, 40, 'migration shouldnt delete when at limit') + done() + }).catch(done) }) it('should not remove any transactions because 20 txs is under the expectable limit', (done) => { storage.meta.version = 22 storage.data.TransactionController.transactions = transactions20 migration23.migrate(storage) - .then((migratedData) => { - const migratedTransactions = migratedData.data.TransactionController.transactions - assert.equal(migratedTransactions.length, 20, 'migration shouldnt delete when under limit') - done() - }).catch(done) + .then((migratedData) => { + const migratedTransactions = migratedData.data.TransactionController.transactions + assert.equal(migratedTransactions.length, 20, 'migration shouldnt delete when under limit') + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/024-test.js b/test/unit/migrations/024-test.js index c7b0611bc..671c7f832 100644 --- a/test/unit/migrations/024-test.js +++ b/test/unit/migrations/024-test.js @@ -28,21 +28,21 @@ storage.data.TransactionController.transactions = transactions describe('storage is migrated successfully and the txParams.from are lowercase', () => { it('should lowercase the from for unapproved txs', (done) => { migration24.migrate(storage) - .then((migratedData) => { - const migratedTransactions = migratedData.data.TransactionController.transactions - migratedTransactions.forEach((tx) => { - if (tx.status === 'unapproved') assert.equal(tx.txParams.from, '0x8acce2391c0d510a6c5e5d8f819a678f79b7e675') - else assert.equal(tx.txParams.from, '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675') - }) - done() - }).catch(done) + .then((migratedData) => { + const migratedTransactions = migratedData.data.TransactionController.transactions + migratedTransactions.forEach((tx) => { + if (tx.status === 'unapproved') assert.equal(tx.txParams.from, '0x8acce2391c0d510a6c5e5d8f819a678f79b7e675') + else assert.equal(tx.txParams.from, '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675') + }) + done() + }).catch(done) }) it('should migrate first time state', (done) => { migration24.migrate(firstTimeState) - .then((migratedData) => { - assert.equal(migratedData.meta.version, 24) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 24) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/025-test.js b/test/unit/migrations/025-test.js index 1e56913a1..fa89bc54f 100644 --- a/test/unit/migrations/025-test.js +++ b/test/unit/migrations/025-test.js @@ -29,21 +29,21 @@ storage.data.TransactionController.transactions = transactions describe('storage is migrated successfully and the txParams.from are lowercase', () => { it('should lowercase the from for unapproved txs', (done) => { migration25.migrate(storage) - .then((migratedData) => { - const migratedTransactions = migratedData.data.TransactionController.transactions - migratedTransactions.forEach((tx) => { - if (tx.status === 'unapproved') assert(!tx.txParams.random) - if (tx.status === 'unapproved') assert(!tx.txParams.chainId) - }) - done() - }).catch(done) + .then((migratedData) => { + const migratedTransactions = migratedData.data.TransactionController.transactions + migratedTransactions.forEach((tx) => { + if (tx.status === 'unapproved') assert(!tx.txParams.random) + if (tx.status === 'unapproved') assert(!tx.txParams.chainId) + }) + done() + }).catch(done) }) it('should migrate first time state', (done) => { migration25.migrate(firstTimeState) - .then((migratedData) => { - assert.equal(migratedData.meta.version, 25) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 25) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/029-test.js b/test/unit/migrations/029-test.js index a2876487b..7f9b8a005 100644 --- a/test/unit/migrations/029-test.js +++ b/test/unit/migrations/029-test.js @@ -19,20 +19,20 @@ const storage = { describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => { it('should auto fail transactions more than 12 hours old', (done) => { migration29.migrate(storage) - .then((migratedData) => { - const txs = migratedData.data.TransactionController.transactions - const [ txMeta1 ] = txs - assert.equal(migratedData.meta.version, 29) + .then((migratedData) => { + const txs = migratedData.data.TransactionController.transactions + const [ txMeta1 ] = txs + assert.equal(migratedData.meta.version, 29) - assert.equal(txMeta1.status, 'failed', 'old tx is auto failed') - assert(txMeta1.err.message.includes('too long'), 'error message assigned') + assert.equal(txMeta1.status, 'failed', 'old tx is auto failed') + assert(txMeta1.err.message.includes('too long'), 'error message assigned') - txs.forEach((tx) => { - if (tx.id === 1) return - assert.notEqual(tx.status, 'failed', 'other tx is not auto failed') - }) + txs.forEach((tx) => { + if (tx.id === 1) return + assert.notEqual(tx.status, 'failed', 'other tx is not auto failed') + }) - done() - }).catch(done) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/030-test.js b/test/unit/migrations/030-test.js index ca410342f..a8e7b4b32 100644 --- a/test/unit/migrations/030-test.js +++ b/test/unit/migrations/030-test.js @@ -25,13 +25,13 @@ const storage = { describe('storage is migrated successfully', () => { it('should work', (done) => { migrationTemplate.migrate(storage) - .then((migratedData) => { - assert.equal(migratedData.meta.version, 30) - assert.equal(migratedData.data.PreferencesController.frequentRpcListDetail[0].chainId, undefined) - assert.equal(migratedData.data.PreferencesController.frequentRpcListDetail[1].chainId, '1') - assert.equal(migratedData.data.NetworkController.provider.chainId, undefined) - assert.equal(migratedData.data.NetworkController.network, undefined) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 30) + assert.equal(migratedData.data.PreferencesController.frequentRpcListDetail[0].chainId, undefined) + assert.equal(migratedData.data.PreferencesController.frequentRpcListDetail[1].chainId, '1') + assert.equal(migratedData.data.NetworkController.provider.chainId, undefined) + assert.equal(migratedData.data.NetworkController.network, undefined) + done() + }).catch(done) }) }) diff --git a/test/unit/migrations/031-test.js b/test/unit/migrations/031-test.js index c85fd7af4..4fcd8b9a5 100644 --- a/test/unit/migrations/031-test.js +++ b/test/unit/migrations/031-test.js @@ -1,7 +1,7 @@ const assert = require('assert') const migration31 = require('../../../app/scripts/migrations/031') - describe('migration #31', () => { +describe('migration #31', () => { it('should set completedOnboarding to true if vault exists', done => { const oldStorage = { 'meta': {}, @@ -23,7 +23,7 @@ const migration31 = require('../../../app/scripts/migrations/031') }, } - migration31.migrate(oldStorage) + migration31.migrate(oldStorage) .then(newStorage => { assert.equal(newStorage.data.PreferencesController.completedOnboarding, true) done() @@ -31,7 +31,7 @@ const migration31 = require('../../../app/scripts/migrations/031') .catch(done) }) - it('should set completedOnboarding to false if vault does not exist', done => { + it('should set completedOnboarding to false if vault does not exist', done => { const oldStorage = { 'meta': {}, 'data': { @@ -46,7 +46,7 @@ const migration31 = require('../../../app/scripts/migrations/031') }, } - migration31.migrate(oldStorage) + migration31.migrate(oldStorage) .then(newStorage => { assert.equal(newStorage.data.PreferencesController.completedOnboarding, false) done() diff --git a/test/unit/migrations/migrations-test.js b/test/unit/migrations/migrations-test.js index 50afd9c2e..563b02a6d 100644 --- a/test/unit/migrations/migrations-test.js +++ b/test/unit/migrations/migrations-test.js @@ -27,82 +27,82 @@ describe('wallet1 is migrated successfully', () => { wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null } return migration2.migrate(wallet1) - .then((secondResult) => { - const secondData = secondResult.data - assert.equal(secondData.config.provider.type, 'rpc', 'provider should be rpc') - assert.equal(secondData.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc') - secondResult.data.config.provider.rpcTarget = oldTestRpc - return migration3.migrate(secondResult) - }).then((thirdResult) => { - assert.equal(thirdResult.data.config.provider.rpcTarget, newTestRpc, 'config.provider.rpcTarget should be set to the proper testrpc url.') - return migration4.migrate(thirdResult) - }).then((fourthResult) => { - const fourthData = fourthResult.data - assert.equal(fourthData.config.provider.rpcTarget, null, 'old rpcTarget should not exist.') - assert.equal(fourthData.config.provider.type, 'testnet', 'config.provider should be set to testnet.') - - return migration5.migrate(vault4) - }).then((fifthResult) => { - const fifthData = fifthResult.data - assert.equal(fifthData.vault, null, 'old vault should not exist') - assert.equal(fifthData.walletNicknames, null, 'old walletNicknames should not exist') - assert.equal(fifthData.config.selectedAccount, null, 'old config.selectedAccount should not exist') - assert.equal(fifthData.KeyringController.vault, vault4.data.vault, 'KeyringController.vault should exist') - assert.equal(fifthData.KeyringController.selectedAccount, vault4.data.config.selectedAccount, 'KeyringController.selectedAccount should have moved') - assert.equal(fifthData.KeyringController.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], vault4.data.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], 'KeyringController.walletNicknames should have moved') - - vault5 = fifthResult - return migration6.migrate(fifthResult) - }).then((sixthResult) => { - assert.equal(sixthResult.data.KeyringController.selectedAccount, null, 'old selectedAccount should not exist') - assert.equal(sixthResult.data.PreferencesController.selectedAddress, vault5.data.KeyringController.selectedAccount, 'selectedAccount should have moved') - - vault6 = sixthResult - return migration7.migrate(sixthResult) - }).then((seventhResult) => { - assert.equal(seventhResult.data.transactions, null, 'old transactions should not exist') - assert.equal(seventhResult.data.gasMultiplier, null, 'old gasMultiplier should not exist') - assert.equal(seventhResult.data.TransactionManager.transactions[0].id, vault6.data.transactions[0].id, 'transactions should have moved') - assert.equal(seventhResult.data.TransactionManager.gasMultiplier, vault6.data.gasMultiplier, 'gasMultiplier should have moved') - - vault7 = seventhResult - return migration8.migrate(seventhResult) - }).then((eighthResult) => { - assert.equal(eighthResult.data.noticesList, null, 'old noticesList should not exist') - assert.equal(eighthResult.data.NoticeController.noticesList[0].title, vault7.data.noticesList[0].title, 'noticesList should have moved') - - vault8 = eighthResult - return migration9.migrate(eighthResult) - }).then((ninthResult) => { - assert.equal(ninthResult.data.currentFiat, null, 'old currentFiat should not exist') - assert.equal(ninthResult.data.fiatCurrency, null, 'old fiatCurrency should not exist') - assert.equal(ninthResult.data.conversionRate, null, 'old conversionRate should not exist') - assert.equal(ninthResult.data.conversionDate, null, 'old conversionDate should not exist') - - assert.equal(ninthResult.data.CurrencyController.currentCurrency, vault8.data.fiatCurrency, 'currentFiat should have moved') - assert.equal(ninthResult.data.CurrencyController.conversionRate, vault8.data.conversionRate, 'conversionRate should have moved') - assert.equal(ninthResult.data.CurrencyController.conversionDate, vault8.data.conversionDate, 'conversionDate should have moved') - - vault9 = ninthResult - return migration10.migrate(ninthResult) - }).then((tenthResult) => { - assert.equal(tenthResult.data.shapeShiftTxList, null, 'old shapeShiftTxList should not exist') - assert.equal(tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction, vault9.data.shapeShiftTxList[0].transaction) - - return migration11.migrate(tenthResult) - }).then((eleventhResult) => { - assert.equal(eleventhResult.data.isDisclaimerConfirmed, null, 'isDisclaimerConfirmed should not exist') - assert.equal(eleventhResult.data.TOSHash, null, 'TOSHash should not exist') - - return migration12.migrate(eleventhResult) - }).then((twelfthResult) => { - assert.equal(twelfthResult.data.NoticeController.noticesList[0].body, '', 'notices that have been read should have an empty body.') - assert.equal(twelfthResult.data.NoticeController.noticesList[1].body, 'nonempty', 'notices that have not been read should not have an empty body.') - - assert.equal(twelfthResult.data.config.provider.type, 'testnet', 'network is originally testnet.') - return migration13.migrate(twelfthResult) - }).then((thirteenthResult) => { - assert.equal(thirteenthResult.data.config.provider.type, 'ropsten', 'network has been changed to ropsten.') - }) + .then((secondResult) => { + const secondData = secondResult.data + assert.equal(secondData.config.provider.type, 'rpc', 'provider should be rpc') + assert.equal(secondData.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc') + secondResult.data.config.provider.rpcTarget = oldTestRpc + return migration3.migrate(secondResult) + }).then((thirdResult) => { + assert.equal(thirdResult.data.config.provider.rpcTarget, newTestRpc, 'config.provider.rpcTarget should be set to the proper testrpc url.') + return migration4.migrate(thirdResult) + }).then((fourthResult) => { + const fourthData = fourthResult.data + assert.equal(fourthData.config.provider.rpcTarget, null, 'old rpcTarget should not exist.') + assert.equal(fourthData.config.provider.type, 'testnet', 'config.provider should be set to testnet.') + + return migration5.migrate(vault4) + }).then((fifthResult) => { + const fifthData = fifthResult.data + assert.equal(fifthData.vault, null, 'old vault should not exist') + assert.equal(fifthData.walletNicknames, null, 'old walletNicknames should not exist') + assert.equal(fifthData.config.selectedAccount, null, 'old config.selectedAccount should not exist') + assert.equal(fifthData.KeyringController.vault, vault4.data.vault, 'KeyringController.vault should exist') + assert.equal(fifthData.KeyringController.selectedAccount, vault4.data.config.selectedAccount, 'KeyringController.selectedAccount should have moved') + assert.equal(fifthData.KeyringController.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], vault4.data.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], 'KeyringController.walletNicknames should have moved') + + vault5 = fifthResult + return migration6.migrate(fifthResult) + }).then((sixthResult) => { + assert.equal(sixthResult.data.KeyringController.selectedAccount, null, 'old selectedAccount should not exist') + assert.equal(sixthResult.data.PreferencesController.selectedAddress, vault5.data.KeyringController.selectedAccount, 'selectedAccount should have moved') + + vault6 = sixthResult + return migration7.migrate(sixthResult) + }).then((seventhResult) => { + assert.equal(seventhResult.data.transactions, null, 'old transactions should not exist') + assert.equal(seventhResult.data.gasMultiplier, null, 'old gasMultiplier should not exist') + assert.equal(seventhResult.data.TransactionManager.transactions[0].id, vault6.data.transactions[0].id, 'transactions should have moved') + assert.equal(seventhResult.data.TransactionManager.gasMultiplier, vault6.data.gasMultiplier, 'gasMultiplier should have moved') + + vault7 = seventhResult + return migration8.migrate(seventhResult) + }).then((eighthResult) => { + assert.equal(eighthResult.data.noticesList, null, 'old noticesList should not exist') + assert.equal(eighthResult.data.NoticeController.noticesList[0].title, vault7.data.noticesList[0].title, 'noticesList should have moved') + + vault8 = eighthResult + return migration9.migrate(eighthResult) + }).then((ninthResult) => { + assert.equal(ninthResult.data.currentFiat, null, 'old currentFiat should not exist') + assert.equal(ninthResult.data.fiatCurrency, null, 'old fiatCurrency should not exist') + assert.equal(ninthResult.data.conversionRate, null, 'old conversionRate should not exist') + assert.equal(ninthResult.data.conversionDate, null, 'old conversionDate should not exist') + + assert.equal(ninthResult.data.CurrencyController.currentCurrency, vault8.data.fiatCurrency, 'currentFiat should have moved') + assert.equal(ninthResult.data.CurrencyController.conversionRate, vault8.data.conversionRate, 'conversionRate should have moved') + assert.equal(ninthResult.data.CurrencyController.conversionDate, vault8.data.conversionDate, 'conversionDate should have moved') + + vault9 = ninthResult + return migration10.migrate(ninthResult) + }).then((tenthResult) => { + assert.equal(tenthResult.data.shapeShiftTxList, null, 'old shapeShiftTxList should not exist') + assert.equal(tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction, vault9.data.shapeShiftTxList[0].transaction) + + return migration11.migrate(tenthResult) + }).then((eleventhResult) => { + assert.equal(eleventhResult.data.isDisclaimerConfirmed, null, 'isDisclaimerConfirmed should not exist') + assert.equal(eleventhResult.data.TOSHash, null, 'TOSHash should not exist') + + return migration12.migrate(eleventhResult) + }).then((twelfthResult) => { + assert.equal(twelfthResult.data.NoticeController.noticesList[0].body, '', 'notices that have been read should have an empty body.') + assert.equal(twelfthResult.data.NoticeController.noticesList[1].body, 'nonempty', 'notices that have not been read should not have an empty body.') + + assert.equal(twelfthResult.data.config.provider.type, 'testnet', 'network is originally testnet.') + return migration13.migrate(twelfthResult) + }).then((thirteenthResult) => { + assert.equal(thirteenthResult.data.config.provider.type, 'ropsten', 'network has been changed to ropsten.') + }) }) }) diff --git a/test/unit/migrations/migrator-test.js b/test/unit/migrations/migrator-test.js index 693c5830d..3dcc5aff7 100644 --- a/test/unit/migrations/migrator-test.js +++ b/test/unit/migrations/migrator-test.js @@ -40,20 +40,20 @@ describe('Migrator', () => { const migrator = new Migrator({ migrations: stubMigrations }) it('migratedData version should be version 3', (done) => { migrator.migrateData(versionedData) - .then((migratedData) => { - assert.equal(migratedData.meta.version, stubMigrations[2].version) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, stubMigrations[2].version) + done() + }).catch(done) }) it('should match the last version in live migrations', (done) => { const migrator = new Migrator({ migrations: liveMigrations }) migrator.migrateData(firstTimeState) - .then((migratedData) => { - const last = liveMigrations.length - 1 - assert.equal(migratedData.meta.version, liveMigrations[last].version) - done() - }).catch(done) + .then((migratedData) => { + const last = liveMigrations.length - 1 + assert.equal(migratedData.meta.version, liveMigrations[last].version) + done() + }).catch(done) }) it('should emit an error', function (done) { @@ -61,8 +61,8 @@ 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(() => { - }).catch(done) + .then(() => { + }).catch(done) }) }) diff --git a/test/unit/migrations/template-test.js b/test/unit/migrations/template-test.js index 0db69d65a..f606cce6f 100644 --- a/test/unit/migrations/template-test.js +++ b/test/unit/migrations/template-test.js @@ -8,9 +8,9 @@ const storage = { describe('storage is migrated successfully', () => { it('should work', (done) => { migrationTemplate.migrate(storage) - .then((migratedData) => { - assert.equal(migratedData.meta.version, 0) - done() - }).catch(done) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 0) + done() + }).catch(done) }) }) diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index 919bd81a6..5bf82a185 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -628,7 +628,7 @@ describe('Actions', () => { { type: 'DISPLAY_WARNING', value: 'error' }, { type: 'HIDE_LOADING_INDICATION' }, { type: 'LOCK_METAMASK' }, - ] + ] backgroundSetLockedSpy = sinon.stub(background, 'setLocked') backgroundSetLockedSpy.callsFake(callback => { callback(new Error('error')) diff --git a/test/web3/schema.js b/test/web3/schema.js index 61977f140..336060431 100644 --- a/test/web3/schema.js +++ b/test/web3/schema.js @@ -173,7 +173,7 @@ var methods = { eth_getUncleByBlockNumberAndIndex: [ 'eth_getUncleByBlockNumberAndIndex', - params.uncleByBlockNumberAndIndexParams, + params.uncleByBlockNumberAndIndexParams, params.block, 2, ], diff --git a/test/web3/web3.js b/test/web3/web3.js index 0f7a4c3cd..8f319f38e 100644 --- a/test/web3/web3.js +++ b/test/web3/web3.js @@ -27,8 +27,8 @@ web3.currentProvider.enable().then(() => { }) }) - }) - }) + }) +}) -- cgit