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.
82 lines
2.2 KiB
82 lines
2.2 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import firstTimeState from '../first-time-state';
|
||
|
import migration28 from './028';
|
||
6 years ago
|
|
||
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: [
|
||
|
{ address: '0xa', symbol: 'A', decimals: 4 },
|
||
|
{ address: '0xb', symbol: 'B', decimals: 4 },
|
||
|
],
|
||
|
identities: {
|
||
6 years ago
|
'0x6d14': {},
|
||
|
'0x3695': {},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
5 years ago
|
describe('migration #28', function () {
|
||
|
it('should add corresponding tokens to accountTokens', function (done) {
|
||
4 years ago
|
migration28
|
||
|
.migrate(oldStorage)
|
||
6 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
const newTokens = newStorage.data.PreferencesController.tokens;
|
||
4 years ago
|
const newAccountTokens =
|
||
4 years ago
|
newStorage.data.PreferencesController.accountTokens;
|
||
6 years ago
|
|
||
4 years ago
|
const testTokens = [
|
||
|
{ address: '0xa', symbol: 'A', decimals: 4 },
|
||
|
{ address: '0xb', symbol: 'B', decimals: 4 },
|
||
4 years ago
|
];
|
||
4 years ago
|
assert.equal(
|
||
|
newTokens.length,
|
||
|
0,
|
||
|
'tokens is expected to have the length of 0',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.equal(
|
||
|
newAccountTokens['0x6d14'].mainnet.length,
|
||
|
2,
|
||
|
'tokens for address is expected to have the length of 2',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.equal(
|
||
|
newAccountTokens['0x3695'].mainnet.length,
|
||
|
2,
|
||
|
'tokens for address is expected to have the length of 2',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.equal(
|
||
|
Object.keys(newAccountTokens).length,
|
||
|
2,
|
||
|
'account tokens should be created for all identities',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.deepEqual(
|
||
|
newAccountTokens['0x6d14'].mainnet,
|
||
|
testTokens,
|
||
|
'tokens for address should be the same than before',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.deepEqual(
|
||
|
newAccountTokens['0x3695'].mainnet,
|
||
|
testTokens,
|
||
|
'tokens for address should be the same than before',
|
||
4 years ago
|
);
|
||
|
done();
|
||
6 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('should successfully migrate first time state', function (done) {
|
||
4 years ago
|
migration28
|
||
|
.migrate({
|
||
|
meta: {},
|
||
|
data: firstTimeState,
|
||
|
})
|
||
6 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
assert.equal(migratedData.meta.version, migration28.version);
|
||
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|