2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration37 from './037';
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('migration #37', function () {
|
|
|
|
it('should update the version metadata', function (done) {
|
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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration37
|
|
|
|
.migrate(oldStorage)
|
2019-09-21 19:36:06 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 37,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-09-21 19:36:06 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should transform old state to new format', function (done) {
|
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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration37
|
|
|
|
.migrate(oldStorage)
|
2019-09-21 19:36:06 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
2020-11-03 00:41:28 +01:00
|
|
|
4: {
|
2019-09-21 19:36:06 +02:00
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 3',
|
|
|
|
},
|
|
|
|
'0x32Be343B94f860124dC4fEe278FDCBD38C102D88': {
|
|
|
|
address: '0x32Be343B94f860124dC4fEe278FDCBD38C102D88',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
2: {
|
2019-09-21 19:36:06 +02:00
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA93': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA93',
|
|
|
|
chainId: '2',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'account 2',
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-09-21 19:36:06 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-09-21 19:36:06 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('ens validation test', function (done) {
|
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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration37
|
|
|
|
.migrate(oldStorage)
|
2019-09-21 19:36:06 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
2020-11-03 00:41:28 +01:00
|
|
|
4: {
|
2019-09-21 19:36:06 +02:00
|
|
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
|
|
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
|
|
|
chainId: '4',
|
|
|
|
isEns: true,
|
|
|
|
memo: '',
|
|
|
|
name: 'metamask.eth',
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-09-21 19:36:06 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|