You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.3 KiB
125 lines
3.3 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import migration37 from './037';
|
||
5 years ago
|
|
||
5 years ago
|
describe('migration #37', function () {
|
||
|
it('should update the version metadata', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {
|
||
|
version: 36,
|
||
5 years ago
|
},
|
||
4 years ago
|
data: {},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration37
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.meta, {
|
||
4 years ago
|
version: 37,
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should transform old state to new format', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
AddressBookController: {
|
||
|
addressBook: {
|
||
5 years ago
|
'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',
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration37
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
||
4 years ago
|
4: {
|
||
5 years ago
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
||
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
||
|
chainId: '4',
|
||
|
isEns: false,
|
||
|
memo: '',
|
||
|
name: 'account 3',
|
||
|
},
|
||
|
'0x32Be343B94f860124dC4fEe278FDCBD38C102D88': {
|
||
|
address: '0x32Be343B94f860124dC4fEe278FDCBD38C102D88',
|
||
|
chainId: '4',
|
||
|
isEns: false,
|
||
|
memo: '',
|
||
|
name: 'account 2',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
2: {
|
||
5 years ago
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA93': {
|
||
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA93',
|
||
|
chainId: '2',
|
||
|
isEns: false,
|
||
|
memo: '',
|
||
|
name: 'account 2',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('ens validation test', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
AddressBookController: {
|
||
|
addressBook: {
|
||
5 years ago
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
||
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
||
|
chainId: '4',
|
||
|
memo: '',
|
||
|
name: 'metamask.eth',
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration37
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
||
4 years ago
|
4: {
|
||
5 years ago
|
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
||
|
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
||
|
chainId: '4',
|
||
|
isEns: true,
|
||
|
memo: '',
|
||
|
name: 'metamask.eth',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|