2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import firstTimeState from '../first-time-state';
|
|
|
|
import migration26 from './026';
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2018-04-19 05:33:51 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: { version: 25 },
|
|
|
|
data: {
|
|
|
|
PreferencesController: {},
|
|
|
|
KeyringController: {
|
|
|
|
walletNicknames: {
|
2018-04-19 05:33:51 +02:00
|
|
|
'0x1e77e2': 'Test Account 1',
|
|
|
|
'0x7e57e2': 'Test Account 2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-04-19 05:33:51 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('migration #26', function () {
|
|
|
|
it('should move the identities from KeyringController', function (done) {
|
2020-11-03 00:41:28 +01:00
|
|
|
migration26
|
|
|
|
.migrate(oldStorage)
|
2018-04-19 05:33:51 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { identities } = newStorage.data.PreferencesController;
|
2018-04-19 05:33:51 +02:00
|
|
|
assert.deepEqual(identities, {
|
2019-12-03 21:50:55 +01:00
|
|
|
'0x1e77e2': { name: 'Test Account 1', address: '0x1e77e2' },
|
|
|
|
'0x7e57e2': { name: 'Test Account 2', address: '0x7e57e2' },
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.strictEqual(
|
|
|
|
newStorage.data.KeyringController.walletNicknames,
|
|
|
|
undefined,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
done();
|
2018-04-19 05:33:51 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2018-04-19 05:33:51 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should successfully migrate first time state', function (done) {
|
2020-11-03 00:41:28 +01:00
|
|
|
migration26
|
|
|
|
.migrate({
|
|
|
|
meta: {},
|
|
|
|
data: firstTimeState,
|
|
|
|
})
|
2018-04-19 05:33:51 +02:00
|
|
|
.then((migratedData) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.equal(migratedData.meta.version, migration26.version);
|
|
|
|
done();
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|