|
|
|
@ -59,13 +59,14 @@ describe('migration #48', function () { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should delete NetworkController.provider if the type is "rpc"', async function () { |
|
|
|
|
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (1)', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rpc', |
|
|
|
|
chainId: 'foo', |
|
|
|
|
fizz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
@ -78,13 +79,86 @@ describe('migration #48', function () { |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rinkeby', |
|
|
|
|
rpcUrl: '', |
|
|
|
|
chainId: '0x4', |
|
|
|
|
nickname: '', |
|
|
|
|
rpcPrefs: {}, |
|
|
|
|
ticker: 'ETH', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (2)', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rpc', |
|
|
|
|
chainId: '0x01', |
|
|
|
|
fizz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const newStorage = await migration48.migrate(oldStorage) |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rinkeby', |
|
|
|
|
rpcUrl: '', |
|
|
|
|
chainId: '0x4', |
|
|
|
|
nickname: '', |
|
|
|
|
rpcPrefs: {}, |
|
|
|
|
ticker: 'ETH', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should not migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is valid', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rpc', |
|
|
|
|
chainId: '0x1', |
|
|
|
|
fizz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const newStorage = await migration48.migrate(oldStorage) |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rpc', |
|
|
|
|
chainId: '0x1', |
|
|
|
|
fizz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should delete NetworkController.provider if the type is "localhost"', async function () { |
|
|
|
|
it('should migrate NetworkController.provider to Rinkeby if the type is "localhost"', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
@ -103,6 +177,14 @@ describe('migration #48', function () { |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
NetworkController: { |
|
|
|
|
provider: { |
|
|
|
|
type: 'rinkeby', |
|
|
|
|
rpcUrl: '', |
|
|
|
|
chainId: '0x4', |
|
|
|
|
nickname: '', |
|
|
|
|
rpcPrefs: {}, |
|
|
|
|
ticker: 'ETH', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
@ -189,4 +271,81 @@ describe('migration #48', function () { |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should delete CachedBalancesController.cachedBalances', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
|
CachedBalancesController: { |
|
|
|
|
cachedBalances: { |
|
|
|
|
fizz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
bar: { |
|
|
|
|
baz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const newStorage = await migration48.migrate(oldStorage) |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
CachedBalancesController: { |
|
|
|
|
bar: { |
|
|
|
|
baz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should convert hex transaction metamaskNetworkId values to decimal', async function () { |
|
|
|
|
const oldStorage = { |
|
|
|
|
meta: {}, |
|
|
|
|
data: { |
|
|
|
|
TransactionController: { |
|
|
|
|
transactions: [ |
|
|
|
|
{ fizz: 'buzz' }, |
|
|
|
|
null, |
|
|
|
|
undefined, |
|
|
|
|
0, |
|
|
|
|
'', |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '1' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '0x1' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: 'kaplar' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '0X2a' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '3' }, |
|
|
|
|
], |
|
|
|
|
bar: { |
|
|
|
|
baz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const newStorage = await migration48.migrate(oldStorage) |
|
|
|
|
assert.deepEqual(newStorage.data, { |
|
|
|
|
...expectedPreferencesState, |
|
|
|
|
TransactionController: { |
|
|
|
|
transactions: [ |
|
|
|
|
{ fizz: 'buzz' }, |
|
|
|
|
null, |
|
|
|
|
undefined, |
|
|
|
|
0, |
|
|
|
|
'', |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '1' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '1' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: 'kaplar' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '42' }, |
|
|
|
|
{ foo: 'bar', metamaskNetworkId: '3' }, |
|
|
|
|
], |
|
|
|
|
bar: { |
|
|
|
|
baz: 'buzz', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
foo: 'bar', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|