2021-03-16 22:00:08 +01:00
|
|
|
import migration37 from './037';
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #37', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2019-09-21 19:36:06 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 36,
|
2019-09-21 19:36:06 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration37.migrate(oldStorage);
|
|
|
|
expect(newStorage.meta.version).toStrictEqual(37);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should transform old state to new format', async () => {
|
2019-09-21 19:36:06 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
AddressBookController: {
|
|
|
|
addressBook: {
|
2019-09-21 19:36:06 +02:00
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
memo: '',
|
|
|
|
name: 'account 3',
|
|
|
|
},
|
|
|
|
'0x32Be343B94f860124dC4fEe278FDCBD38C102D88': {
|
|
|
|
address: '0x32Be343B94f860124dC4fEe278FDCBD38C102D88',
|
|
|
|
chainId: '4',
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
// there are no repeated addresses by the current implementation
|
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA93': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA93',
|
|
|
|
chainId: '2',
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration37.migrate(oldStorage);
|
|
|
|
expect(newStorage.data.AddressBookController.addressBook).toStrictEqual({
|
|
|
|
4: {
|
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 3',
|
|
|
|
},
|
|
|
|
'0x32Be343B94f860124dC4fEe278FDCBD38C102D88': {
|
|
|
|
address: '0x32Be343B94f860124dC4fEe278FDCBD38C102D88',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA93': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA93',
|
|
|
|
chainId: '2',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('ens validation test', async () => {
|
2019-09-21 19:36:06 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
AddressBookController: {
|
|
|
|
addressBook: {
|
2019-09-21 19:36:06 +02:00
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
memo: '',
|
|
|
|
name: 'metamask.eth',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration37.migrate(oldStorage);
|
|
|
|
expect(newStorage.data.AddressBookController.addressBook).toStrictEqual({
|
|
|
|
4: {
|
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: true,
|
|
|
|
memo: '',
|
|
|
|
name: 'metamask.eth',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|