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.
436 lines
11 KiB
436 lines
11 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import migration39 from './039';
|
||
5 years ago
|
|
||
5 years ago
|
describe('migration #39', function () {
|
||
|
it('should update the version metadata', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {
|
||
|
version: 38,
|
||
5 years ago
|
},
|
||
4 years ago
|
data: {},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.meta, {
|
||
4 years ago
|
version: 39,
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should update old DAI token symbol to SAI in tokens', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: [
|
||
|
{
|
||
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
|
},
|
||
|
{
|
||
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
symbol: 'BAT',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
{
|
||
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
symbol: 'META',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
],
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
||
4 years ago
|
tokens: [
|
||
|
{
|
||
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'SAI',
|
||
|
},
|
||
|
{
|
||
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
symbol: 'BAT',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
{
|
||
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
symbol: 'META',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
],
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should update old DAI token symbol to SAI in accountTokens', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
accountTokens: {
|
||
5 years ago
|
'0x7250739de134d33ec7ab1ee592711e15098c9d2d': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
'0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5': {
|
||
4 years ago
|
mainnet: [],
|
||
|
rinkeby: [],
|
||
5 years ago
|
},
|
||
|
'0x8e5d75d60224ea0c33d1041e75de68b1c3cb6dd5': {},
|
||
|
'0xb3958fb96c8201486ae20be1d5c9f58083df343a': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
decimals: 18,
|
||
|
symbol: 'BAT',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
decimals: 18,
|
||
|
symbol: 'META',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
||
4 years ago
|
accountTokens: {
|
||
5 years ago
|
'0x7250739de134d33ec7ab1ee592711e15098c9d2d': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'SAI',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
'0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5': {
|
||
4 years ago
|
mainnet: [],
|
||
|
rinkeby: [],
|
||
5 years ago
|
},
|
||
|
'0x8e5d75d60224ea0c33d1041e75de68b1c3cb6dd5': {},
|
||
|
'0xb3958fb96c8201486ae20be1d5c9f58083df343a': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'SAI',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
decimals: 18,
|
||
|
symbol: 'BAT',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
decimals: 18,
|
||
|
symbol: 'META',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if accountTokens is not an object', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
accountTokens: [],
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if accountTokens is an object with invalid values', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
accountTokens: {
|
||
5 years ago
|
'0x7250739de134d33ec7ab1ee592711e15098c9d2d': [
|
||
|
{
|
||
4 years ago
|
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
'0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359': null,
|
||
|
'0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5': {
|
||
4 years ago
|
mainnet: [null, undefined, [], 42],
|
||
|
rinkeby: null,
|
||
5 years ago
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if accountTokens includes the new DAI token', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
accountTokens: {
|
||
5 years ago
|
'0x7250739de134d33ec7ab1ee592711e15098c9d2d': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
'0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5': {
|
||
4 years ago
|
mainnet: [],
|
||
|
rinkeby: [],
|
||
5 years ago
|
},
|
||
|
'0x8e5d75d60224ea0c33d1041e75de68b1c3cb6dd5': {},
|
||
|
'0xb3958fb96c8201486ae20be1d5c9f58083df343a': {
|
||
4 years ago
|
mainnet: [
|
||
5 years ago
|
{
|
||
4 years ago
|
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||
|
decimals: 18,
|
||
|
symbol: 'DAI',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
decimals: 18,
|
||
|
symbol: 'BAT',
|
||
5 years ago
|
},
|
||
|
{
|
||
4 years ago
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
decimals: 18,
|
||
|
symbol: 'META',
|
||
5 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if tokens includes the new DAI token', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: [
|
||
|
{
|
||
|
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||
|
symbol: 'DAI',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
{
|
||
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
symbol: 'META',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
],
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if tokens does not include DAI', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: [
|
||
|
{
|
||
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||
|
symbol: 'BAT',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
{
|
||
|
address: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||
|
symbol: 'META',
|
||
|
decimals: 18,
|
||
|
},
|
||
|
],
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if a tokens property has invalid entries', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: [null, [], undefined, 42],
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if a tokens property is not an array', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: {},
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if a tokens property is null', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
tokens: null,
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if a tokens property is missing', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {},
|
||
5 years ago
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if a accountTokens property is missing', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {},
|
||
5 years ago
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration39
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|