1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Complete migration tests.

This commit is contained in:
Kevin Serrano 2017-02-15 11:15:47 -08:00
parent 6ddd613a15
commit d0e2846eca
No known key found for this signature in database
GPG Key ID: 7CC862A58D2889B4
2 changed files with 75 additions and 15 deletions

View File

@ -117,6 +117,7 @@
"brfs": "^1.4.3", "brfs": "^1.4.3",
"browserify": "^13.0.0", "browserify": "^13.0.0",
"chai": "^3.5.0", "chai": "^3.5.0",
"clone": "^1.0.2",
"deep-freeze-strict": "^1.1.1", "deep-freeze-strict": "^1.1.1",
"del": "^2.2.0", "del": "^2.2.0",
"fs-promise": "^1.0.0", "fs-promise": "^1.0.0",

View File

@ -2,36 +2,95 @@ const assert = require('assert')
const path = require('path') const path = require('path')
const wallet1 = require(path.join('..', 'lib', 'migrations', '001.json')) const wallet1 = require(path.join('..', 'lib', 'migrations', '001.json'))
const vault4 = require(path.join('..', 'lib', 'migrations', '004.json'))
let vault5, vault6, vault7, vault8, vault9, vault10, vault11
const migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002')) const migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002'))
const migration3 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '003')) const migration3 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '003'))
const migration4 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '004')) const migration4 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '004'))
const migration5 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '005'))
const migration6 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '006'))
const migration7 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '007'))
const migration8 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '008'))
const migration9 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '009'))
const migration10 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '010'))
const migration11 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '011')) const migration11 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '011'))
const oldTestRpc = 'https://rawtestrpc.metamask.io/' const oldTestRpc = 'https://rawtestrpc.metamask.io/'
const newTestRpc = 'https://testrpc.metamask.io/' const newTestRpc = 'https://testrpc.metamask.io/'
describe('wallet1 is migrated successfully', function() { describe('wallet1 is migrated successfully', () => {
it('should convert providers', function() { it('should convert providers', () => {
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null } wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }
return migration2.migrate(wallet1) return migration2.migrate(wallet1)
.then((firstResult) => { .then((secondResult) => {
assert.equal(firstResult.data.config.provider.type, 'rpc', 'provider should be rpc') const secondData = secondResult.data
assert.equal(firstResult.data.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc') assert.equal(secondData.config.provider.type, 'rpc', 'provider should be rpc')
firstResult.data.config.provider.rpcTarget = oldTestRpc assert.equal(secondData.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc')
return migration3.migrate(firstResult) secondResult.data.config.provider.rpcTarget = oldTestRpc
}).then((secondResult) => { return migration3.migrate(secondResult)
assert.equal(secondResult.data.config.provider.rpcTarget, newTestRpc)
return migration4.migrate(secondResult)
}).then((thirdResult) => { }).then((thirdResult) => {
assert.equal(thirdResult.data.config.provider.rpcTarget, null) assert.equal(thirdResult.data.config.provider.rpcTarget, newTestRpc, 'config.provider.rpcTarget should be set to the proper testrpc url.')
assert.equal(thirdResult.data.config.provider.type, 'testnet') return migration4.migrate(thirdResult)
return migration11.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) => { }).then((eleventhResult) => {
assert.equal(eleventhResult.data.isDisclaimerConfirmed, null) assert.equal(eleventhResult.data.isDisclaimerConfirmed, null, 'isDisclaimerConfirmed should not exist')
assert.equal(eleventhResult.data.TOSHash, null) assert.equal(eleventhResult.data.TOSHash, null, 'TOSHash should not exist')
}) })
}) })