aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/migrations-test.js
blob: 9ea8d5c5ad001eabaf88ab6724772b3a0c7e1e9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var assert = require('assert')
var path = require('path')

var wallet1 = require(path.join('..', 'lib', 'migrations', '001.json'))

var migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002'))
var migration3 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '003'))
var migration4 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '004'))

describe('wallet1 is migrated successfully', function() {

  it('should convert providers', function(done) {

    wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }

    var firstResult = migration2.migrate(wallet1.data)
    assert.equal(firstResult.config.provider.type, 'rpc', 'provider should be rpc')
    assert.equal(firstResult.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc')

    var oldTestRpc = 'https://rawtestrpc.metamask.io/'
    var newTestRpc = 'https://testrpc.metamask.io/'
    firstResult.config.provider.rpcTarget = oldTestRpc

    var secondResult = migration3.migrate(firstResult)
    assert.equal(secondResult.config.provider.rpcTarget, newTestRpc)

    var thirdResult = migration4.migrate(secondResult)
    assert.equal(secondResult.config.provider.rpcTarget, null)
    assert.equal(secondResult.config.provider.type, 'testnet')

    done()
  })
})