mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
088d4c34f1
* Remove network config store * Remove inline networks variable in network controller * Re-key network controller 'rpcTarget' to 'rpcUrl' * Require chainId in lookupNetwork, implement eth_chainId * Require chain ID in network form * Add alert, migrations, and tests * Add chainId validation to addToFrequentRpcList * Update public config state selector to match new network controller state * Use network enums in networks-tab.constants * Ensure chainId in provider config is current * Update tests
127 lines
2.8 KiB
JavaScript
127 lines
2.8 KiB
JavaScript
import { strict as assert } from 'assert'
|
|
import migration48 from '../../../app/scripts/migrations/048'
|
|
|
|
describe('migration #48', function () {
|
|
it('should update the version metadata', async function () {
|
|
const oldStorage = {
|
|
'meta': {
|
|
'version': 47,
|
|
},
|
|
'data': {},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(newStorage.meta, {
|
|
'version': 48,
|
|
})
|
|
})
|
|
|
|
it('should delete NetworkController.settings', async function () {
|
|
const oldStorage = {
|
|
meta: {},
|
|
data: {
|
|
NetworkController: {
|
|
settings: {
|
|
fizz: 'buzz',
|
|
},
|
|
provider: {
|
|
type: 'notRpc',
|
|
},
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(newStorage.data, {
|
|
NetworkController: {
|
|
provider: {
|
|
type: 'notRpc',
|
|
},
|
|
},
|
|
foo: 'bar',
|
|
})
|
|
})
|
|
|
|
it('should delete NetworkController.provider if the type is "rpc"', async function () {
|
|
const oldStorage = {
|
|
meta: {},
|
|
data: {
|
|
NetworkController: {
|
|
provider: {
|
|
type: 'rpc',
|
|
fizz: 'buzz',
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(newStorage.data, {
|
|
NetworkController: {
|
|
foo: 'bar',
|
|
},
|
|
foo: 'bar',
|
|
})
|
|
})
|
|
|
|
it('should re-key NetworkController.provider.rpcTarget to rpcUrl if the type is not "rpc"', async function () {
|
|
const oldStorage = {
|
|
meta: {},
|
|
data: {
|
|
NetworkController: {
|
|
provider: {
|
|
type: 'someType',
|
|
rpcTarget: 'foo.xyz',
|
|
fizz: 'buzz',
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(newStorage.data, {
|
|
NetworkController: {
|
|
foo: 'bar',
|
|
provider: {
|
|
type: 'someType',
|
|
rpcUrl: 'foo.xyz',
|
|
fizz: 'buzz',
|
|
},
|
|
},
|
|
foo: 'bar',
|
|
})
|
|
})
|
|
|
|
it('should do nothing if affected state does not exist', async function () {
|
|
const oldStorage = {
|
|
meta: {},
|
|
data: {
|
|
NetworkController: {
|
|
provider: {
|
|
type: 'notRpc',
|
|
},
|
|
},
|
|
foo: 'bar',
|
|
},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(oldStorage.data, newStorage.data)
|
|
})
|
|
|
|
it('should do nothing if state is empty', async function () {
|
|
const oldStorage = {
|
|
meta: {},
|
|
data: {},
|
|
}
|
|
|
|
const newStorage = await migration48.migrate(oldStorage)
|
|
assert.deepEqual(oldStorage.data, newStorage.data)
|
|
})
|
|
})
|