mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Jestify migrations/ (#12106)
* Jestify migrations/ * Lint exclude migrations from mocha config, and add inclusion to jest config * Add migration tests to jest config * Exclude/ignore migration tests * Set process.env.IN_TEST to true when running tests locally
This commit is contained in:
parent
c35797453d
commit
e78e82205a
@ -133,6 +133,7 @@ module.exports = {
|
||||
'ui/__mocks__/*.js',
|
||||
'shared/**/*.test.js',
|
||||
'development/**/*.test.js',
|
||||
'app/scripts/migrations/*.test.js',
|
||||
],
|
||||
extends: ['@metamask/eslint-config-mocha'],
|
||||
rules: {
|
||||
@ -155,6 +156,7 @@ module.exports = {
|
||||
'ui/__mocks__/*.js',
|
||||
'shared/**/*.test.js',
|
||||
'development/**/*.test.js',
|
||||
'app/scripts/migrations/*.test.js',
|
||||
],
|
||||
extends: ['@metamask/eslint-config-jest'],
|
||||
rules: {
|
||||
|
@ -1,17 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import wallet2 from '../../../test/lib/migrations/002.json';
|
||||
import migration21 from './021';
|
||||
|
||||
describe('wallet2 is migrated successfully with out the BlacklistController', function () {
|
||||
it('should delete BlacklistController key', function (done) {
|
||||
migration21
|
||||
.migrate(wallet2)
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, 21);
|
||||
assert(!migratedData.data.BlacklistController);
|
||||
assert(!migratedData.data.RecentBlocks);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
describe('wallet2 is migrated successfully with out the BlacklistController', () => {
|
||||
it('should delete BlacklistController key', async () => {
|
||||
const migratedData = await migration21.migrate(wallet2);
|
||||
expect(migratedData.meta.version).toStrictEqual(21);
|
||||
expect(!migratedData.data.BlacklistController).toStrictEqual(true);
|
||||
expect(!migratedData.data.RecentBlocks).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration22 from './022';
|
||||
|
||||
@ -16,25 +15,21 @@ const storage = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||||
it('should add submittedTime key on the txMeta if appropriate', function (done) {
|
||||
migration22
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
|
||||
it('should add submittedTime key on the txMeta if appropriate', async () => {
|
||||
const migratedData = await migration22.migrate(storage);
|
||||
const [
|
||||
txMeta1,
|
||||
txMeta2,
|
||||
txMeta3,
|
||||
] = migratedData.data.TransactionController.transactions;
|
||||
assert.equal(migratedData.meta.version, 22);
|
||||
|
||||
expect(migratedData.meta.version).toStrictEqual(22);
|
||||
// should have written a submitted time
|
||||
assert(txMeta1.submittedTime);
|
||||
expect.anything(txMeta1.submittedTime);
|
||||
// should not have written a submitted time because it already has one
|
||||
assert.equal(txMeta2.submittedTime, properTime);
|
||||
expect(txMeta2.submittedTime).toStrictEqual(properTime);
|
||||
// should not have written a submitted time
|
||||
assert(!txMeta3.submittedTime);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
expect(!txMeta3.submittedTime).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration23 from './023';
|
||||
|
||||
@ -52,11 +51,10 @@ while (transactions20.length < 20) {
|
||||
|
||||
storage.data.TransactionController.transactions = transactions;
|
||||
|
||||
describe('storage is migrated successfully and the proper transactions are remove from state', function () {
|
||||
it('should remove transactions that are unneeded', function (done) {
|
||||
migration23
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
describe('storage is migrated successfully and the proper transactions are remove from state', () => {
|
||||
it('should remove transactions that are unneeded', async () => {
|
||||
const migratedData = await migration23.migrate(storage);
|
||||
|
||||
let leftoverNonDeletableTxCount = 0;
|
||||
const migratedTransactions =
|
||||
migratedData.data.TransactionController.transactions;
|
||||
@ -65,54 +63,31 @@ describe('storage is migrated successfully and the proper transactions are remov
|
||||
leftoverNonDeletableTxCount += 1;
|
||||
}
|
||||
});
|
||||
assert.equal(
|
||||
leftoverNonDeletableTxCount,
|
||||
nonDeletableCount,
|
||||
"migration shouldn't delete transactions we want to keep",
|
||||
);
|
||||
assert(
|
||||
migratedTransactions.length >= 40,
|
||||
`should be equal or greater to 40 if they are non deletable states got ${migratedTransactions.length} transactions`,
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
|
||||
expect(leftoverNonDeletableTxCount).toStrictEqual(nonDeletableCount);
|
||||
|
||||
expect(migratedTransactions.length >= 40).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('should not remove any transactions because 40 is the expected limit', function (done) {
|
||||
it('should not remove any transactions because 40 is the expected limit', async () => {
|
||||
storage.meta.version = 22;
|
||||
storage.data.TransactionController.transactions = transactions40;
|
||||
migration23
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
|
||||
const migratedData = await migration23.migrate(storage);
|
||||
const migratedTransactions =
|
||||
migratedData.data.TransactionController.transactions;
|
||||
|
||||
assert.equal(
|
||||
migratedTransactions.length,
|
||||
40,
|
||||
"migration shouldn't delete when at limit",
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
expect(migratedTransactions).toHaveLength(40);
|
||||
});
|
||||
|
||||
it('should not remove any transactions because 20 txs is under the expected limit', function (done) {
|
||||
it('should not remove any transactions because 20 txs is under the expected limit', async () => {
|
||||
storage.meta.version = 22;
|
||||
storage.data.TransactionController.transactions = transactions20;
|
||||
migration23
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
|
||||
const migratedData = await migration23.migrate(storage);
|
||||
const migratedTransactions =
|
||||
migratedData.data.TransactionController.transactions;
|
||||
assert.equal(
|
||||
migratedTransactions.length,
|
||||
20,
|
||||
"migration shouldn't delete when under limit",
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
|
||||
expect(migratedTransactions).toHaveLength(20);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
/* eslint-disable jest/no-conditional-expect */
|
||||
import data from '../first-time-state';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration24 from './024';
|
||||
@ -31,38 +31,27 @@ while (transactions.length <= 10) {
|
||||
|
||||
storage.data.TransactionController.transactions = transactions;
|
||||
|
||||
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
|
||||
it('should lowercase the from for unapproved txs', function (done) {
|
||||
migration24
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
||||
it('should lowercase the from for unapproved txs', async () => {
|
||||
const migratedData = await migration24.migrate(storage);
|
||||
const migratedTransactions =
|
||||
migratedData.data.TransactionController.transactions;
|
||||
|
||||
migratedTransactions.forEach((tx) => {
|
||||
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||
assert.equal(
|
||||
tx.txParams.from,
|
||||
expect(tx.txParams.from).toStrictEqual(
|
||||
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
||||
);
|
||||
} else {
|
||||
assert.equal(
|
||||
tx.txParams.from,
|
||||
expect(tx.txParams.from).toStrictEqual(
|
||||
'0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
|
||||
);
|
||||
}
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should migrate first time state', function (done) {
|
||||
migration24
|
||||
.migrate(firstTimeState)
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, 24);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
it('should migrate first time state', async () => {
|
||||
const migratedData = await migration24.migrate(firstTimeState);
|
||||
expect(migratedData.meta.version).toStrictEqual(24);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
/* eslint-disable jest/no-conditional-expect */
|
||||
import data from '../first-time-state';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration25 from './025';
|
||||
@ -36,33 +36,25 @@ while (transactions.length <= 10) {
|
||||
|
||||
storage.data.TransactionController.transactions = transactions;
|
||||
|
||||
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
|
||||
it('should lowercase the from for unapproved txs', function (done) {
|
||||
migration25
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
||||
it('should lowercase the from for unapproved txs', async () => {
|
||||
const migratedData = await migration25.migrate(storage);
|
||||
|
||||
const migratedTransactions =
|
||||
migratedData.data.TransactionController.transactions;
|
||||
migratedTransactions.forEach((tx) => {
|
||||
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||
assert(!tx.txParams.random);
|
||||
expect(!tx.txParams.random).toStrictEqual(true);
|
||||
}
|
||||
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||
assert(!tx.txParams.chainId);
|
||||
expect(!tx.txParams.chainId).toStrictEqual(true);
|
||||
}
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should migrate first time state', function (done) {
|
||||
migration25
|
||||
.migrate(firstTimeState)
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, 25);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
it('should migrate first time state', async () => {
|
||||
const migratedData = await migration25.migrate(firstTimeState);
|
||||
|
||||
expect(migratedData.meta.version).toStrictEqual(25);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import firstTimeState from '../first-time-state';
|
||||
import migration26 from './026';
|
||||
|
||||
@ -15,35 +14,25 @@ const oldStorage = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('migration #26', function () {
|
||||
it('should move the identities from KeyringController', function (done) {
|
||||
migration26
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
describe('migration #26', () => {
|
||||
it('should move the identities from KeyringController', async () => {
|
||||
const newStorage = await migration26.migrate(oldStorage);
|
||||
|
||||
const { identities } = newStorage.data.PreferencesController;
|
||||
assert.deepEqual(identities, {
|
||||
|
||||
expect(identities).toStrictEqual({
|
||||
'0x1e77e2': { name: 'Test Account 1', address: '0x1e77e2' },
|
||||
'0x7e57e2': { name: 'Test Account 2', address: '0x7e57e2' },
|
||||
});
|
||||
assert.strictEqual(
|
||||
newStorage.data.KeyringController.walletNicknames,
|
||||
undefined,
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
|
||||
expect(newStorage.data.KeyringController.walletNicknames).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should successfully migrate first time state', function (done) {
|
||||
migration26
|
||||
.migrate({
|
||||
it('should successfully migrate first time state', async () => {
|
||||
const migratedData = await migration26.migrate({
|
||||
meta: {},
|
||||
data: firstTimeState,
|
||||
})
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, migration26.version);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
expect(migratedData.meta.version).toStrictEqual(migration26.version);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import firstTimeState from '../first-time-state';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration27 from './027';
|
||||
@ -22,38 +21,27 @@ while (transactions.length < 9) {
|
||||
|
||||
oldStorage.data.TransactionController.transactions = transactions;
|
||||
|
||||
describe('migration #27', function () {
|
||||
it('should remove rejected transactions', function (done) {
|
||||
migration27
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
const newTransactions =
|
||||
newStorage.data.TransactionController.transactions;
|
||||
assert.equal(
|
||||
newTransactions.length,
|
||||
6,
|
||||
'transactions is expected to have the length of 6',
|
||||
);
|
||||
describe('migration #27', () => {
|
||||
it('should remove rejected transactions', async () => {
|
||||
const newStorage = await migration27.migrate(oldStorage);
|
||||
|
||||
const newTransactions = newStorage.data.TransactionController.transactions;
|
||||
|
||||
expect(newTransactions).toHaveLength(6);
|
||||
|
||||
newTransactions.forEach((txMeta) => {
|
||||
if (txMeta.status === TRANSACTION_STATUSES.REJECTED) {
|
||||
done(new Error('transaction was found with a status of rejected'));
|
||||
throw new Error('transaction was found with a status of rejected');
|
||||
}
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should successfully migrate first time state', function (done) {
|
||||
migration27
|
||||
.migrate({
|
||||
it('should successfully migrate first time state', async () => {
|
||||
const migratedData = await migration27.migrate({
|
||||
meta: {},
|
||||
data: firstTimeState,
|
||||
})
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, migration27.version);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
expect(migratedData.meta.version).toStrictEqual(migration27.version);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import firstTimeState from '../first-time-state';
|
||||
import migration28 from './028';
|
||||
|
||||
@ -18,11 +17,10 @@ const oldStorage = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('migration #28', function () {
|
||||
it('should add corresponding tokens to accountTokens', function (done) {
|
||||
migration28
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
describe('migration #28', () => {
|
||||
it('should add corresponding tokens to accountTokens', async () => {
|
||||
const newStorage = await migration28.migrate(oldStorage);
|
||||
|
||||
const newTokens = newStorage.data.PreferencesController.tokens;
|
||||
const newAccountTokens =
|
||||
newStorage.data.PreferencesController.accountTokens;
|
||||
@ -31,51 +29,25 @@ describe('migration #28', function () {
|
||||
{ address: '0xa', symbol: 'A', decimals: 4 },
|
||||
{ address: '0xb', symbol: 'B', decimals: 4 },
|
||||
];
|
||||
assert.equal(
|
||||
newTokens.length,
|
||||
0,
|
||||
'tokens is expected to have the length of 0',
|
||||
);
|
||||
assert.equal(
|
||||
newAccountTokens['0x6d14'].mainnet.length,
|
||||
2,
|
||||
'tokens for address is expected to have the length of 2',
|
||||
);
|
||||
assert.equal(
|
||||
newAccountTokens['0x3695'].mainnet.length,
|
||||
2,
|
||||
'tokens for address is expected to have the length of 2',
|
||||
);
|
||||
assert.equal(
|
||||
Object.keys(newAccountTokens).length,
|
||||
2,
|
||||
'account tokens should be created for all identities',
|
||||
);
|
||||
assert.deepEqual(
|
||||
newAccountTokens['0x6d14'].mainnet,
|
||||
testTokens,
|
||||
'tokens for address should be the same than before',
|
||||
);
|
||||
assert.deepEqual(
|
||||
newAccountTokens['0x3695'].mainnet,
|
||||
testTokens,
|
||||
'tokens for address should be the same than before',
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
expect(newTokens).toHaveLength(0);
|
||||
|
||||
expect(newAccountTokens['0x6d14'].mainnet).toHaveLength(2);
|
||||
|
||||
expect(newAccountTokens['0x3695'].mainnet).toHaveLength(2);
|
||||
|
||||
expect(Object.keys(newAccountTokens)).toHaveLength(2);
|
||||
|
||||
expect(newAccountTokens['0x6d14'].mainnet).toStrictEqual(testTokens);
|
||||
|
||||
expect(newAccountTokens['0x3695'].mainnet).toStrictEqual(testTokens);
|
||||
});
|
||||
|
||||
it('should successfully migrate first time state', function (done) {
|
||||
migration28
|
||||
.migrate({
|
||||
it('should successfully migrate first time state', async () => {
|
||||
const migratedData = await migration28.migrate({
|
||||
meta: {},
|
||||
data: firstTimeState,
|
||||
})
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, migration28.version);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
expect(migratedData.meta.version).toStrictEqual(migration28.version);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||||
import migration29 from './029';
|
||||
|
||||
@ -30,38 +29,20 @@ const storage = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||||
it('should auto fail transactions more than 12 hours old', function (done) {
|
||||
migration29
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
|
||||
it('should auto fail transactions more than 12 hours old', async () => {
|
||||
const migratedData = await migration29.migrate(storage);
|
||||
const txs = migratedData.data.TransactionController.transactions;
|
||||
const [txMeta1] = txs;
|
||||
assert.equal(migratedData.meta.version, 29);
|
||||
|
||||
assert.equal(
|
||||
txMeta1.status,
|
||||
TRANSACTION_STATUSES.FAILED,
|
||||
'old tx is auto failed',
|
||||
);
|
||||
assert(
|
||||
txMeta1.err.message.includes('too long'),
|
||||
'error message assigned',
|
||||
);
|
||||
expect(migratedData.meta.version).toStrictEqual(29);
|
||||
expect(txMeta1.status).toStrictEqual(TRANSACTION_STATUSES.FAILED);
|
||||
|
||||
txs.forEach((tx) => {
|
||||
if (tx.id === 1) {
|
||||
return;
|
||||
}
|
||||
assert.notEqual(
|
||||
tx.status,
|
||||
TRANSACTION_STATUSES.FAILED,
|
||||
'other tx is not auto failed',
|
||||
);
|
||||
expect(tx.status).not.toStrictEqual(TRANSACTION_STATUSES.FAILED);
|
||||
});
|
||||
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migrationTemplate from './030';
|
||||
|
||||
const storage = {
|
||||
@ -33,29 +32,20 @@ const storage = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('storage is migrated successfully', function () {
|
||||
it('should work', function (done) {
|
||||
migrationTemplate
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, 30);
|
||||
assert.equal(
|
||||
migratedData.data.PreferencesController.frequentRpcListDetail[0]
|
||||
.chainId,
|
||||
undefined,
|
||||
);
|
||||
assert.equal(
|
||||
migratedData.data.PreferencesController.frequentRpcListDetail[1]
|
||||
.chainId,
|
||||
'1',
|
||||
);
|
||||
assert.equal(
|
||||
describe('storage is migrated successfully', () => {
|
||||
it('should work', async () => {
|
||||
const migratedData = await migrationTemplate.migrate(storage);
|
||||
|
||||
expect(migratedData.meta.version).toStrictEqual(30);
|
||||
expect(
|
||||
migratedData.data.PreferencesController.frequentRpcListDetail[0].chainId,
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
migratedData.data.PreferencesController.frequentRpcListDetail[1].chainId,
|
||||
).toStrictEqual('1');
|
||||
expect(
|
||||
migratedData.data.NetworkController.provider.chainId,
|
||||
undefined,
|
||||
);
|
||||
assert.equal(migratedData.data.NetworkController.network, undefined);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
).toBeUndefined();
|
||||
expect(migratedData.data.NetworkController.network).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration31 from './031';
|
||||
|
||||
describe('migration #31', function () {
|
||||
it('should set completedOnboarding to true if vault exists', function (done) {
|
||||
describe('migration #31', () => {
|
||||
it('should set completedOnboarding to true if vault exists', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -26,19 +25,14 @@ describe('migration #31', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration31
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.equal(
|
||||
const newStorage = await migration31.migrate(oldStorage);
|
||||
|
||||
expect(
|
||||
newStorage.data.PreferencesController.completedOnboarding,
|
||||
true,
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('should set completedOnboarding to false if vault does not exist', function (done) {
|
||||
it('should set completedOnboarding to false if vault does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -56,15 +50,9 @@ describe('migration #31', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration31
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.equal(
|
||||
const newStorage = await migration31.migrate(oldStorage);
|
||||
expect(
|
||||
newStorage.data.PreferencesController.completedOnboarding,
|
||||
false,
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration33 from './033';
|
||||
|
||||
describe('Migration to delete notice controller', function () {
|
||||
describe('Migration to delete notice controller', () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -31,9 +30,8 @@ describe('Migration to delete notice controller', function () {
|
||||
},
|
||||
};
|
||||
|
||||
it('removes notice controller from state', function () {
|
||||
migration33.migrate(oldStorage).then((newStorage) => {
|
||||
assert.equal(newStorage.data.NoticeController, undefined);
|
||||
});
|
||||
it('removes notice controller from state', async () => {
|
||||
const newStorage = await migration33.migrate(oldStorage);
|
||||
expect(newStorage.data.NoticeController).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration34 from './034';
|
||||
|
||||
describe('migration #34', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #34', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 33,
|
||||
@ -10,18 +9,11 @@ describe('migration #34', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 34,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(34);
|
||||
});
|
||||
|
||||
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', function (done) {
|
||||
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -33,21 +25,16 @@ describe('migration #34', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({
|
||||
migratedPrivacyMode: true,
|
||||
featureFlags: {
|
||||
privacyMode: true,
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should NOT change any state if migratedPrivacyMode is already set to true', function (done) {
|
||||
it('should NOT change any state if migratedPrivacyMode is already set to true', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -60,16 +47,11 @@ describe('migration #34', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if migratedPrivacyMode is already set to false', function (done) {
|
||||
it('should NOT change any state if migratedPrivacyMode is already set to false', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -82,31 +64,21 @@ describe('migration #34', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||
it('should NOT change any state if PreferencesController is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if featureFlags.privacyMode is already true', function (done) {
|
||||
it('should NOT change any state if featureFlags.privacyMode is already true', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -118,12 +90,7 @@ describe('migration #34', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration34
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration34.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration35 from './035';
|
||||
|
||||
describe('migration #35', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #35', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 34,
|
||||
@ -10,18 +9,11 @@ describe('migration #35', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration35
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 35,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration35.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(35);
|
||||
});
|
||||
|
||||
it('should delete seedWords', function (done) {
|
||||
it('should delete seedWords', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -31,16 +23,11 @@ describe('migration #35', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration35
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration35.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({});
|
||||
});
|
||||
|
||||
it('should delete falsy seedWords', function (done) {
|
||||
it('should delete falsy seedWords', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -50,16 +37,11 @@ describe('migration #35', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration35
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration35.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({});
|
||||
});
|
||||
|
||||
it('should leave state without seedWords unchanged', function (done) {
|
||||
it('should leave state without seedWords unchanged', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -88,12 +70,7 @@ describe('migration #35', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration35
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration35.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration36 from './036';
|
||||
|
||||
describe('migration #36', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #36', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 35,
|
||||
@ -10,18 +9,11 @@ describe('migration #36', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 36,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(36);
|
||||
});
|
||||
|
||||
it('should remove privacyMode if featureFlags.privacyMode was false', function (done) {
|
||||
it('should remove privacyMode if featureFlags.privacyMode was false', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -33,18 +25,13 @@ describe('migration #36', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({
|
||||
featureFlags: {},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should remove privacyMode if featureFlags.privacyMode was true', function (done) {
|
||||
it('should remove privacyMode if featureFlags.privacyMode was true', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -56,18 +43,13 @@ describe('migration #36', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({
|
||||
featureFlags: {},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should NOT change any state if privacyMode does not exist', function (done) {
|
||||
it('should NOT change any state if privacyMode does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -78,31 +60,21 @@ describe('migration #36', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||
it('should NOT change any state if PreferencesController is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if featureFlags is missing', function (done) {
|
||||
it('should NOT change any state if featureFlags is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -110,12 +82,7 @@ describe('migration #36', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration36
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration36.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration37 from './037';
|
||||
|
||||
describe('migration #37', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #37', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 36,
|
||||
@ -10,18 +9,11 @@ describe('migration #37', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration37
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 37,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration37.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(37);
|
||||
});
|
||||
|
||||
it('should transform old state to new format', function (done) {
|
||||
it('should transform old state to new format', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -51,10 +43,8 @@ describe('migration #37', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration37
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
||||
const newStorage = await migration37.migrate(oldStorage);
|
||||
expect(newStorage.data.AddressBookController.addressBook).toStrictEqual({
|
||||
4: {
|
||||
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
||||
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
||||
@ -81,12 +71,9 @@ describe('migration #37', function () {
|
||||
},
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('ens validation test', function (done) {
|
||||
it('ens validation test', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -103,10 +90,8 @@ describe('migration #37', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration37
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.AddressBookController.addressBook, {
|
||||
const newStorage = await migration37.migrate(oldStorage);
|
||||
expect(newStorage.data.AddressBookController.addressBook).toStrictEqual({
|
||||
4: {
|
||||
'0x1De7e54679bfF0c23856FbF547b2394e723FCA91': {
|
||||
address: '0x1De7e54679bfF0c23856FbF547b2394e723FCA91',
|
||||
@ -117,8 +102,5 @@ describe('migration #37', function () {
|
||||
},
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration38 from './038';
|
||||
|
||||
describe('migration #38', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #38', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 37,
|
||||
@ -10,36 +9,23 @@ describe('migration #38', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration38
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 38,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration38.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(38);
|
||||
});
|
||||
|
||||
it('should add a fullScreenVsPopup property set to either "control" or "fullScreen"', function (done) {
|
||||
it('should add a fullScreenVsPopup property set to either "control" or "fullScreen"', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration38
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.equal(
|
||||
newStorage.data.ABTestController.abTests.fullScreenVsPopup,
|
||||
'control',
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration38.migrate(oldStorage);
|
||||
expect(
|
||||
newStorage.data.ABTestController?.abTests?.fullScreenVsPopup,
|
||||
).toStrictEqual('control');
|
||||
});
|
||||
|
||||
it('should leave the fullScreenVsPopup property unchanged if it exists', function (done) {
|
||||
it('should leave the fullScreenVsPopup property unchanged if it exists', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -51,16 +37,9 @@ describe('migration #38', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration38
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.ABTestController, {
|
||||
abTests: {
|
||||
fullScreenVsPopup: 'fullScreen',
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration38.migrate(oldStorage);
|
||||
expect(
|
||||
newStorage.data.ABTestController?.abTests?.fullScreenVsPopup,
|
||||
).toStrictEqual('fullScreen');
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration39 from './039';
|
||||
|
||||
describe('migration #39', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #39', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 38,
|
||||
@ -10,18 +9,11 @@ describe('migration #39', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 39,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(39);
|
||||
});
|
||||
|
||||
it('should update old DAI token symbol to SAI in tokens', function (done) {
|
||||
it('should update old DAI token symbol to SAI in tokens', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -47,10 +39,8 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({
|
||||
tokens: [
|
||||
{
|
||||
address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||||
@ -69,12 +59,9 @@ describe('migration #39', function () {
|
||||
},
|
||||
],
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should update old DAI token symbol to SAI in accountTokens', function (done) {
|
||||
it('should update old DAI token symbol to SAI in accountTokens', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -118,10 +105,8 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data.PreferencesController, {
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual({
|
||||
accountTokens: {
|
||||
'0x7250739de134d33ec7ab1ee592711e15098c9d2d': {
|
||||
mainnet: [
|
||||
@ -158,12 +143,9 @@ describe('migration #39', function () {
|
||||
},
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should NOT change any state if accountTokens is not an object', function (done) {
|
||||
it('should NOT change any state if accountTokens is not an object', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -173,16 +155,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if accountTokens is an object with invalid values', function (done) {
|
||||
it('should NOT change any state if accountTokens is an object with invalid values', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -205,16 +182,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if accountTokens includes the new DAI token', function (done) {
|
||||
it('should NOT change any state if accountTokens includes the new DAI token', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -258,16 +230,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if tokens includes the new DAI token', function (done) {
|
||||
it('should NOT change any state if tokens includes the new DAI token', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -288,16 +255,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if tokens does not include DAI', function (done) {
|
||||
it('should NOT change any state if tokens does not include DAI', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -318,16 +280,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if a tokens property has invalid entries', function (done) {
|
||||
it('should NOT change any state if a tokens property has invalid entries', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -337,16 +294,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if a tokens property is not an array', function (done) {
|
||||
it('should NOT change any state if a tokens property is not an array', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -356,16 +308,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if a tokens property is null', function (done) {
|
||||
it('should NOT change any state if a tokens property is null', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -375,16 +322,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if a tokens property is missing', function (done) {
|
||||
it('should NOT change any state if a tokens property is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -392,16 +334,11 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if a accountTokens property is missing', function (done) {
|
||||
it('should NOT change any state if a accountTokens property is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -409,27 +346,17 @@ describe('migration #39', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||
it('should NOT change any state if PreferencesController is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration39
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration39.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration40 from './040';
|
||||
|
||||
describe('migration #40', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #40', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 39,
|
||||
@ -10,18 +9,11 @@ describe('migration #40', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration40
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 40,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration40.migrate(oldStorage);
|
||||
expect(newStorage.meta?.version).toStrictEqual(40);
|
||||
});
|
||||
|
||||
it('should delete ProviderApprovalController storage key', function (done) {
|
||||
it('should delete ProviderApprovalController storage key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -30,27 +22,21 @@ describe('migration #40', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration40
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, { foo: 'bar' });
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration40.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if no ProviderApprovalController storage key', function (done) {
|
||||
it('should do nothing if no ProviderApprovalController storage key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: { foo: 'bar' },
|
||||
};
|
||||
|
||||
migration40
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, { foo: 'bar' });
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration40.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration41 from './041';
|
||||
|
||||
describe('migration #41', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #41', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 40,
|
||||
@ -10,18 +9,11 @@ describe('migration #41', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration41
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 41,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration41.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(41);
|
||||
});
|
||||
|
||||
it('should rename autoLogoutTimeLimit storage key', function (done) {
|
||||
it('should rename autoLogoutTimeLimit storage key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -36,10 +28,8 @@ describe('migration #41', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration41
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration41.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
preferences: {
|
||||
autoLockTimeLimit: 42,
|
||||
@ -49,12 +39,9 @@ describe('migration #41', function () {
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should do nothing if no PreferencesController key', function (done) {
|
||||
it('should do nothing if no PreferencesController key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -62,18 +49,13 @@ describe('migration #41', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration41
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration41.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should do nothing if no preferences key', function (done) {
|
||||
it('should do nothing if no preferences key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -84,17 +66,12 @@ describe('migration #41', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration41
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration41.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration42 from './042';
|
||||
|
||||
describe('migration #42', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #42', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 41,
|
||||
@ -10,18 +9,11 @@ describe('migration #42', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration42
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
version: 42,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const newStorage = await migration42.migrate(oldStorage);
|
||||
expect(newStorage.meta.version).toStrictEqual(42);
|
||||
});
|
||||
|
||||
it('should set connectedStatusPopoverHasBeenShown to false', function (done) {
|
||||
it('should set connectedStatusPopoverHasBeenShown to false', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -33,22 +25,17 @@ describe('migration #42', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration42
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration42.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
AppStateController: {
|
||||
connectedStatusPopoverHasBeenShown: false,
|
||||
bar: 'baz',
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should initialize AppStateController if it does not exist', function (done) {
|
||||
it('should initialize AppStateController if it does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -56,17 +43,12 @@ describe('migration #42', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration42
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration42.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
AppStateController: {
|
||||
connectedStatusPopoverHasBeenShown: false,
|
||||
},
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration43 from './043';
|
||||
|
||||
describe('migration #43', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #43', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 42,
|
||||
@ -11,12 +10,12 @@ describe('migration #43', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration43.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 43,
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete currentAccountTab state', async function () {
|
||||
it('should delete currentAccountTab state', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -29,7 +28,7 @@ describe('migration #43', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration43.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -37,7 +36,7 @@ describe('migration #43', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if currentAccountTab state does not exist', async function () {
|
||||
it('should do nothing if currentAccountTab state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -49,6 +48,6 @@ describe('migration #43', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration43.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration44 from './044';
|
||||
|
||||
describe('migration #44', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #44', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 43,
|
||||
@ -11,12 +10,12 @@ describe('migration #44', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration44.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 44,
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete mkrMigrationReminderTimestamp state', async function () {
|
||||
it('should delete mkrMigrationReminderTimestamp state', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -29,7 +28,7 @@ describe('migration #44', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration44.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
AppStateController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -37,7 +36,7 @@ describe('migration #44', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete mkrMigrationReminderTimestamp state if it is null', async function () {
|
||||
it('should delete mkrMigrationReminderTimestamp state if it is null', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -50,7 +49,7 @@ describe('migration #44', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration44.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
AppStateController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -58,7 +57,7 @@ describe('migration #44', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if mkrMigrationReminderTimestamp state does not exist', async function () {
|
||||
it('should do nothing if mkrMigrationReminderTimestamp state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -70,6 +69,6 @@ describe('migration #44', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration44.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration45 from './045';
|
||||
|
||||
describe('migration #45', function () {
|
||||
it('should update the version metadata', function (done) {
|
||||
describe('migration #45', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 44,
|
||||
@ -10,18 +9,13 @@ describe('migration #45', function () {
|
||||
data: {},
|
||||
};
|
||||
|
||||
migration45
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
const newStorage = await migration45.migrate(oldStorage);
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 45,
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should update ipfsGateway value if outdated', function (done) {
|
||||
it('should update ipfsGateway value if outdated', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -33,22 +27,17 @@ describe('migration #45', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration45
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration45.migrate(oldStorage);
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
ipfsGateway: 'dweb.link',
|
||||
bar: 'baz',
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should not update ipfsGateway value if custom set', function (done) {
|
||||
it('should not update ipfsGateway value if custom set', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -60,22 +49,18 @@ describe('migration #45', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration45
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration45.migrate(oldStorage);
|
||||
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
ipfsGateway: 'blah',
|
||||
bar: 'baz',
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should do nothing if no PreferencesController key', function (done) {
|
||||
it('should do nothing if no PreferencesController key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -83,14 +68,10 @@ describe('migration #45', function () {
|
||||
},
|
||||
};
|
||||
|
||||
migration45
|
||||
.migrate(oldStorage)
|
||||
.then((newStorage) => {
|
||||
assert.deepEqual(newStorage.data, {
|
||||
const newStorage = await migration45.migrate(oldStorage);
|
||||
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration46 from './046';
|
||||
|
||||
describe('migration #46', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #46', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 45,
|
||||
@ -11,12 +10,12 @@ describe('migration #46', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration46.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 46,
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete ABTestController state', async function () {
|
||||
it('should delete ABTestController state', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -30,12 +29,12 @@ describe('migration #46', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration46.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if ABTestController state does not exist', async function () {
|
||||
it('should do nothing if ABTestController state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -47,6 +46,6 @@ describe('migration #46', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration46.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration47 from './047';
|
||||
|
||||
describe('migration #47', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #47', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 46,
|
||||
@ -11,12 +10,12 @@ describe('migration #47', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 47,
|
||||
});
|
||||
});
|
||||
|
||||
it('should stringify transactions metamaskNetworkId values', async function () {
|
||||
it('should stringify transactions metamaskNetworkId values', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -33,7 +32,7 @@ describe('migration #47', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: [
|
||||
{ foo: 'bar', metamaskNetworkId: '2' },
|
||||
@ -46,7 +45,7 @@ describe('migration #47', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if transactions metamaskNetworkId values are already strings', async function () {
|
||||
it('should do nothing if transactions metamaskNetworkId values are already strings', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -63,10 +62,10 @@ describe('migration #47', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state does not exist', async function () {
|
||||
it('should do nothing if transactions state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -78,10 +77,10 @@ describe('migration #47', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state is empty', async function () {
|
||||
it('should do nothing if transactions state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -94,16 +93,16 @@ describe('migration #47', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if state is empty', async function () {
|
||||
it('should do nothing if state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
const newStorage = await migration47.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration48 from './048';
|
||||
|
||||
const localhostNetwork = {
|
||||
@ -18,8 +17,8 @@ const expectedPreferencesState = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('migration #48', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #48', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 47,
|
||||
@ -28,12 +27,12 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 48,
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete NetworkController.settings', async function () {
|
||||
it('should delete NetworkController.settings', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -50,7 +49,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
provider: {
|
||||
@ -61,7 +60,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (1)', async function () {
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (1)', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -78,7 +77,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
provider: {
|
||||
@ -95,7 +94,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (2)', async function () {
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is invalid (2)', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -112,7 +111,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
provider: {
|
||||
@ -129,7 +128,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is valid', async function () {
|
||||
it('should not migrate NetworkController.provider to Rinkeby if the type is "rpc" and the chainId is valid', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -146,7 +145,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
provider: {
|
||||
@ -160,7 +159,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "localhost"', async function () {
|
||||
it('should migrate NetworkController.provider to Rinkeby if the type is "localhost"', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -176,7 +175,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
provider: {
|
||||
@ -193,7 +192,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should re-key NetworkController.provider.rpcTarget to rpcUrl if the type is not "rpc" or "localhost"', async function () {
|
||||
it('should re-key NetworkController.provider.rpcTarget to rpcUrl if the type is not "rpc" or "localhost"', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -210,7 +209,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
NetworkController: {
|
||||
foo: 'bar',
|
||||
@ -224,7 +223,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing to NetworkController if affected state does not exist', async function () {
|
||||
it('should do nothing to NetworkController if affected state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -238,13 +237,13 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(
|
||||
{ ...expectedPreferencesState, ...oldStorage.data },
|
||||
{ ...expectedPreferencesState, ...newStorage.data },
|
||||
);
|
||||
expect({ ...expectedPreferencesState, ...oldStorage.data }).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
...newStorage.data,
|
||||
});
|
||||
});
|
||||
|
||||
it('should add frequentRpcListDetail item to beginning of list', async function () {
|
||||
it('should add frequentRpcListDetail item to beginning of list', async () => {
|
||||
const existingList = [
|
||||
{ rpcUrl: 'foo', chainId: '0x1' },
|
||||
{ rpcUrl: 'bar', chainId: '0x2' },
|
||||
@ -261,7 +260,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
frequentRpcListDetail: [{ ...localhostNetwork }, ...existingList],
|
||||
},
|
||||
@ -269,7 +268,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete CachedBalancesController.cachedBalances', async function () {
|
||||
it('should delete CachedBalancesController.cachedBalances', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -286,7 +285,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
CachedBalancesController: {
|
||||
bar: {
|
||||
@ -297,7 +296,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert hex transaction metamaskNetworkId values to decimal', async function () {
|
||||
it('should convert hex transaction metamaskNetworkId values to decimal', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -323,7 +322,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
TransactionController: {
|
||||
transactions: [
|
||||
@ -346,7 +345,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate the address book', async function () {
|
||||
it('should migrate the address book', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -380,7 +379,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
AddressBookController: {
|
||||
addressBook: {
|
||||
@ -411,7 +410,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate the address book and merge entries', async function () {
|
||||
it('should migrate the address book and merge entries', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -452,7 +451,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
AddressBookController: {
|
||||
addressBook: {
|
||||
@ -483,7 +482,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not modify address book if all entries are valid or un-parseable', async function () {
|
||||
it('should not modify address book if all entries are valid or un-parseable', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -501,7 +500,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
AddressBookController: {
|
||||
addressBook: {
|
||||
@ -516,7 +515,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete localhost key in IncomingTransactionsController', async function () {
|
||||
it('should delete localhost key in IncomingTransactionsController', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -532,7 +531,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
IncomingTransactionsController: {
|
||||
incomingTxLastFetchedBlocksByNetwork: {
|
||||
@ -544,7 +543,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not modify IncomingTransactionsController state if affected key is missing', async function () {
|
||||
it('should not modify IncomingTransactionsController state if affected key is missing', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -560,7 +559,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
...expectedPreferencesState,
|
||||
IncomingTransactionsController: {
|
||||
incomingTxLastFetchedBlocksByNetwork: {
|
||||
@ -573,7 +572,7 @@ describe('migration #48', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should merge localhost token list into rpc token list', async function () {
|
||||
it('should merge localhost token list into rpc token list', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -604,7 +603,7 @@ describe('migration #48', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration48.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountTokens: {
|
||||
address1: {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration49 from './049';
|
||||
|
||||
describe('migration #49', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #49', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 48,
|
||||
@ -11,12 +10,12 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 49,
|
||||
});
|
||||
});
|
||||
|
||||
it('should move metaMetricsId to MetaMetricsController', async function () {
|
||||
it('should move metaMetricsId to MetaMetricsController', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -29,7 +28,7 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -40,7 +39,7 @@ describe('migration #49', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should move participateInMetaMetrics to MetaMetricsController', async function () {
|
||||
it('should move participateInMetaMetrics to MetaMetricsController', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -53,7 +52,7 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -64,7 +63,7 @@ describe('migration #49', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should move metaMetricsSendCount to MetaMetricsController', async function () {
|
||||
it('should move metaMetricsSendCount to MetaMetricsController', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -77,7 +76,7 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -88,7 +87,7 @@ describe('migration #49', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should move all metaMetrics fields to MetaMetricsController', async function () {
|
||||
it('should move all metaMetrics fields to MetaMetricsController', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -103,7 +102,7 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -116,7 +115,7 @@ describe('migration #49', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if no PreferencesController key', async function () {
|
||||
it('should do nothing if no PreferencesController key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -125,7 +124,7 @@ describe('migration #49', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration49.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import sinon from 'sinon';
|
||||
import migration50 from './050';
|
||||
|
||||
@ -14,18 +13,21 @@ const LEGACY_LOCAL_STORAGE_KEYS = [
|
||||
'GAS_API_ESTIMATES',
|
||||
];
|
||||
|
||||
describe('migration #50', function () {
|
||||
describe('migration #50', () => {
|
||||
let mockLocalStorageRemoveItem;
|
||||
|
||||
beforeEach(function () {
|
||||
mockLocalStorageRemoveItem = sinon.stub(window.localStorage, 'removeItem');
|
||||
beforeEach(() => {
|
||||
mockLocalStorageRemoveItem = jest
|
||||
// eslint-disable-next-line no-undef
|
||||
.spyOn(Storage.prototype, 'removeItem')
|
||||
.mockImplementation();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it('should update the version metadata', async function () {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 49,
|
||||
@ -34,12 +36,12 @@ describe('migration #50', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration50.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 50,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call window.localStorage.removeItem for each legacy key', async function () {
|
||||
it('should call window.localStorage.removeItem for each legacy key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 49,
|
||||
@ -48,41 +50,32 @@ describe('migration #50', function () {
|
||||
};
|
||||
|
||||
await migration50.migrate(oldStorage);
|
||||
assert.equal(mockLocalStorageRemoveItem.callCount, 9);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(0).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls).toHaveLength(9);
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[0][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[0],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(1).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[1][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[1],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(2).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[2][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[2],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(3).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[3][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[3],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(4).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[4][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[4],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(5).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[5][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[5],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(6).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[6][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[6],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(7).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[7][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[7],
|
||||
);
|
||||
assert.equal(
|
||||
mockLocalStorageRemoveItem.getCall(8).args[0],
|
||||
expect(mockLocalStorageRemoveItem.mock.calls[8][0]).toStrictEqual(
|
||||
LEGACY_LOCAL_STORAGE_KEYS[8],
|
||||
);
|
||||
});
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import {
|
||||
INFURA_PROVIDER_TYPES,
|
||||
NETWORK_TYPE_TO_ID_MAP,
|
||||
} from '../../../shared/constants/network';
|
||||
import migration51 from './051';
|
||||
|
||||
describe('migration #51', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #51', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 50,
|
||||
@ -15,14 +14,14 @@ describe('migration #51', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration51.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 51,
|
||||
});
|
||||
});
|
||||
|
||||
describe('setting chainId', function () {
|
||||
describe('setting chainId', () => {
|
||||
INFURA_PROVIDER_TYPES.forEach(function (type) {
|
||||
it(`should correctly set the chainId for the Infura network "${type}", if no chainId is set`, async function () {
|
||||
it(`should correctly set the chainId for the Infura network "${type}", if no chainId is set`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -38,7 +37,7 @@ describe('migration #51', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration51.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
NetworkController: {
|
||||
settings: {
|
||||
fizz: 'buzz',
|
||||
@ -52,7 +51,7 @@ describe('migration #51', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should correctly set the chainId for the Infura network "${type}", if an incorrect chainId is set`, async function () {
|
||||
it(`should correctly set the chainId for the Infura network "${type}", if an incorrect chainId is set`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -69,7 +68,7 @@ describe('migration #51', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration51.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
NetworkController: {
|
||||
settings: {
|
||||
fizz: 'buzz',
|
||||
@ -84,7 +83,7 @@ describe('migration #51', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not set the chainId for a non-Infura network that does not have chainId set', async function () {
|
||||
it('should not set the chainId for a non-Infura network that does not have chainId set', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -99,10 +98,10 @@ describe('migration #51', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration51.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
|
||||
it('should not set the chainId for a non-Infura network that does have chainId set', async function () {
|
||||
it('should not set the chainId for a non-Infura network that does have chainId set', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -118,7 +117,7 @@ describe('migration #51', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration51.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import {
|
||||
GOERLI,
|
||||
GOERLI_CHAIN_ID,
|
||||
@ -19,8 +18,8 @@ const TOKEN2 = { symbol: 'TXT', address: '0x11', decimals: 18 };
|
||||
const TOKEN3 = { symbol: 'TVT', address: '0x12', decimals: 18 };
|
||||
const TOKEN4 = { symbol: 'TAT', address: '0x13', decimals: 18 };
|
||||
|
||||
describe('migration #52', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #52', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 52,
|
||||
@ -29,12 +28,12 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 52,
|
||||
});
|
||||
});
|
||||
|
||||
it(`should move ${MAINNET} tokens and hidden tokens to be keyed by ${MAINNET_CHAIN_ID} for each address`, async function () {
|
||||
it(`should move ${MAINNET} tokens and hidden tokens to be keyed by ${MAINNET_CHAIN_ID} for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -62,7 +61,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountHiddenTokens: {
|
||||
'0x1111': {
|
||||
@ -86,7 +85,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should move ${RINKEBY} tokens and hidden tokens to be keyed by ${RINKEBY_CHAIN_ID} for each address`, async function () {
|
||||
it(`should move ${RINKEBY} tokens and hidden tokens to be keyed by ${RINKEBY_CHAIN_ID} for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -114,7 +113,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountHiddenTokens: {
|
||||
'0x1111': {
|
||||
@ -138,7 +137,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should move ${KOVAN} tokens and hidden tokens to be keyed by ${KOVAN_CHAIN_ID} for each address`, async function () {
|
||||
it(`should move ${KOVAN} tokens and hidden tokens to be keyed by ${KOVAN_CHAIN_ID} for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -166,7 +165,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountHiddenTokens: {
|
||||
'0x1111': {
|
||||
@ -190,7 +189,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should move ${GOERLI} tokens and hidden tokens to be keyed by ${GOERLI_CHAIN_ID} for each address`, async function () {
|
||||
it(`should move ${GOERLI} tokens and hidden tokens to be keyed by ${GOERLI_CHAIN_ID} for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -218,7 +217,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountHiddenTokens: {
|
||||
'0x1111': {
|
||||
@ -242,7 +241,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should move ${ROPSTEN} tokens and hidden tokens to be keyed by ${ROPSTEN_CHAIN_ID} for each address`, async function () {
|
||||
it(`should move ${ROPSTEN} tokens and hidden tokens to be keyed by ${ROPSTEN_CHAIN_ID} for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -270,7 +269,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountHiddenTokens: {
|
||||
'0x1111': {
|
||||
@ -294,7 +293,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should duplicate ${NETWORK_TYPE_RPC} tokens and hidden tokens to all custom networks for each address`, async function () {
|
||||
it(`should duplicate ${NETWORK_TYPE_RPC} tokens and hidden tokens to all custom networks for each address`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -327,7 +326,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
frequentRpcListDetail: [
|
||||
{ chainId: '0xab' },
|
||||
@ -364,7 +363,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should overwrite ${NETWORK_TYPE_RPC} tokens with built in networks if chainIds match`, async function () {
|
||||
it(`should overwrite ${NETWORK_TYPE_RPC} tokens with built in networks if chainIds match`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -389,7 +388,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
frequentRpcListDetail: [{ chainId: '0x1' }],
|
||||
accountHiddenTokens: {
|
||||
@ -408,7 +407,7 @@ describe('migration #52', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if no PreferencesController key', async function () {
|
||||
it('should do nothing if no PreferencesController key', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -417,7 +416,7 @@ describe('migration #52', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration52.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
foo: 'bar',
|
||||
});
|
||||
});
|
||||
|
@ -1,11 +1,10 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TRANSACTION_TYPES } from '../../../shared/constants/transaction';
|
||||
import migration53 from './053';
|
||||
|
||||
const SENT_ETHER = 'sentEther'; // a legacy transaction type replaced now by TRANSACTION_TYPES.SIMPLE_SEND
|
||||
|
||||
describe('migration #53', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #53', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 52,
|
||||
@ -14,12 +13,12 @@ describe('migration #53', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration53.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 53,
|
||||
});
|
||||
});
|
||||
|
||||
it('should update type of standard transactions', async function () {
|
||||
it('should update type of standard transactions', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -62,7 +61,7 @@ describe('migration #53', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration53.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: [
|
||||
{ type: TRANSACTION_TYPES.CANCEL, txParams: { foo: 'bar' } },
|
||||
@ -91,7 +90,7 @@ describe('migration #53', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state does not exist', async function () {
|
||||
it('should do nothing if transactions state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -106,10 +105,10 @@ describe('migration #53', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration53.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state is empty', async function () {
|
||||
it('should do nothing if transactions state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -126,16 +125,16 @@ describe('migration #53', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration53.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if state is empty', async function () {
|
||||
it('should do nothing if state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
const newStorage = await migration53.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import {
|
||||
MAINNET_CHAIN_ID,
|
||||
ROPSTEN_CHAIN_ID,
|
||||
} from '../../../shared/constants/network';
|
||||
import migration54 from './054';
|
||||
|
||||
describe('migration #54', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #54', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 53,
|
||||
@ -15,12 +14,12 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 54,
|
||||
});
|
||||
});
|
||||
|
||||
it('should retype instance of 0 decimal values to numbers [tokens]', async function () {
|
||||
it('should retype instance of 0 decimal values to numbers [tokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -53,7 +52,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
tokens: [
|
||||
{
|
||||
@ -82,7 +81,7 @@ describe('migration #54', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if all decimal value typings are correct [tokens]', async function () {
|
||||
it('should do nothing if all decimal value typings are correct [tokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -115,7 +114,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
tokens: [
|
||||
{
|
||||
@ -144,7 +143,7 @@ describe('migration #54', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should retype instance of 0 decimal values to numbers [accountTokens]', async function () {
|
||||
it('should retype instance of 0 decimal values to numbers [accountTokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -205,7 +204,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountTokens: {
|
||||
'0x1111': {
|
||||
@ -262,7 +261,7 @@ describe('migration #54', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if all decimal value typings are correct [accountTokens]', async function () {
|
||||
it('should do nothing if all decimal value typings are correct [accountTokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -323,7 +322,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountTokens: {
|
||||
'0x1111': {
|
||||
@ -380,7 +379,7 @@ describe('migration #54', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should retype instance of 0 decimal values to numbers [accountTokens and tokens]', async function () {
|
||||
it('should retype instance of 0 decimal values to numbers [accountTokens and tokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -462,7 +461,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountTokens: {
|
||||
'0x1111': {
|
||||
@ -540,7 +539,7 @@ describe('migration #54', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should retype instance of 0 decimal values to numbers, and remove tokens with corrupted decimal values [accountTokens and tokens]', async function () {
|
||||
it('should retype instance of 0 decimal values to numbers, and remove tokens with corrupted decimal values [accountTokens and tokens]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -622,7 +621,7 @@ describe('migration #54', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration54.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
accountTokens: {
|
||||
'0x1111': {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import {
|
||||
GOERLI,
|
||||
GOERLI_CHAIN_ID,
|
||||
@ -13,8 +12,8 @@ import {
|
||||
} from '../../../shared/constants/network';
|
||||
import migration55 from './055';
|
||||
|
||||
describe('migration #55', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #55', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 54,
|
||||
@ -23,12 +22,12 @@ describe('migration #55', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration55.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 55,
|
||||
});
|
||||
});
|
||||
|
||||
it('should replace incomingTxLastFetchedBlocksByNetwork with incomingTxLastFetchedBlockByChainId, and carry over old values', async function () {
|
||||
it('should replace incomingTxLastFetchedBlocksByNetwork with incomingTxLastFetchedBlockByChainId, and carry over old values', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -54,7 +53,7 @@ describe('migration #55', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration55.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
IncomingTransactionsController: {
|
||||
incomingTransactions:
|
||||
oldStorage.data.IncomingTransactionsController.incomingTransactions,
|
||||
@ -70,7 +69,7 @@ describe('migration #55', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if incomingTxLastFetchedBlocksByNetwork key is not populated', async function () {
|
||||
it('should do nothing if incomingTxLastFetchedBlocksByNetwork key is not populated', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -82,15 +81,15 @@ describe('migration #55', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration55.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
it('should do nothing if state is empty', async function () {
|
||||
it('should do nothing if state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
const newStorage = await migration55.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration56 from './056';
|
||||
|
||||
const BAD_TOKEN_DATA = { symbol: null, decimals: null };
|
||||
const TOKEN2 = { symbol: 'TXT', address: '0x11', decimals: 18 };
|
||||
const TOKEN3 = { symbol: 'TVT', address: '0x12', decimals: 18 };
|
||||
|
||||
describe('migration #56', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #56', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 55,
|
||||
@ -21,12 +20,12 @@ describe('migration #56', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration56.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 56,
|
||||
});
|
||||
});
|
||||
|
||||
it(`should filter out tokens without a valid address property`, async function () {
|
||||
it(`should filter out tokens without a valid address property`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -39,13 +38,13 @@ describe('migration #56', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration56.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data.PreferencesController.tokens, [
|
||||
expect(newStorage.data.PreferencesController.tokens).toStrictEqual([
|
||||
TOKEN2,
|
||||
TOKEN3,
|
||||
]);
|
||||
});
|
||||
|
||||
it(`should not filter any tokens when all token information is valid`, async function () {
|
||||
it(`should not filter any tokens when all token information is valid`, async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -58,13 +57,13 @@ describe('migration #56', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration56.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data.PreferencesController.tokens, [
|
||||
expect(newStorage.data.PreferencesController.tokens).toStrictEqual([
|
||||
TOKEN2,
|
||||
TOKEN3,
|
||||
]);
|
||||
});
|
||||
|
||||
it(`should filter out accountTokens without a valid address property`, async function () {
|
||||
it(`should filter out accountTokens without a valid address property`, async () => {
|
||||
const originalAccountTokens = {
|
||||
'0x1111111111111111111111111': {
|
||||
'0x1': [TOKEN2, TOKEN3, BAD_TOKEN_DATA],
|
||||
@ -98,13 +97,12 @@ describe('migration #56', function () {
|
||||
desiredResult['0x1111111111111111111111111']['0x4'] = [];
|
||||
desiredResult['0x1111111111111111111111112']['0x4'] = [];
|
||||
|
||||
assert.deepStrictEqual(
|
||||
newStorage.data.PreferencesController.accountTokens,
|
||||
expect(newStorage.data.PreferencesController.accountTokens).toStrictEqual(
|
||||
desiredResult,
|
||||
);
|
||||
});
|
||||
|
||||
it(`should remove a bad assetImages key`, async function () {
|
||||
it(`should remove a bad assetImages key`, async () => {
|
||||
const desiredAssetImages = {
|
||||
'0x514910771af9ca656af840dff83e8264ecf986ca':
|
||||
'images/contract/chainlink.svg',
|
||||
@ -121,13 +119,12 @@ describe('migration #56', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration56.migrate(oldStorage);
|
||||
assert.deepStrictEqual(
|
||||
newStorage.data.PreferencesController.assetImages,
|
||||
expect(newStorage.data.PreferencesController.assetImages).toStrictEqual(
|
||||
desiredAssetImages,
|
||||
);
|
||||
});
|
||||
|
||||
it(`token data with no problems should preserve all data`, async function () {
|
||||
it(`token data with no problems should preserve all data`, async () => {
|
||||
const perfectData = {
|
||||
tokens: [TOKEN2, TOKEN3],
|
||||
accountTokens: {
|
||||
@ -150,6 +147,6 @@ describe('migration #56', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration56.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data.PreferencesController, perfectData);
|
||||
expect(newStorage.data.PreferencesController).toStrictEqual(perfectData);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration57 from './057';
|
||||
|
||||
describe('migration #57', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #57', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 56,
|
||||
@ -11,12 +10,12 @@ describe('migration #57', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration57.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 57,
|
||||
});
|
||||
});
|
||||
|
||||
it('should transactions array into an object keyed by id', async function () {
|
||||
it('should transactions array into an object keyed by id', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -45,7 +44,7 @@ describe('migration #57', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration57.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: {
|
||||
0: {
|
||||
@ -67,7 +66,7 @@ describe('migration #57', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle transactions without an id, just in case', async function () {
|
||||
it('should handle transactions without an id, just in case', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -98,24 +97,22 @@ describe('migration #57', function () {
|
||||
newStorage.data.TransactionController.transactions,
|
||||
)) {
|
||||
// Make sure each transaction now has an id.
|
||||
assert.ok(
|
||||
typeof transaction.id !== 'undefined',
|
||||
'transaction id is undefined',
|
||||
);
|
||||
expect(typeof transaction.id !== 'undefined').toStrictEqual(true);
|
||||
// Build expected transaction object
|
||||
expectedTransactions[transaction.id] = transaction;
|
||||
}
|
||||
// Ensure that we got the correct number of transactions
|
||||
assert.equal(
|
||||
Object.keys(expectedTransactions).length,
|
||||
expect(Object.keys(expectedTransactions)).toHaveLength(
|
||||
oldStorage.data.TransactionController.transactions.length,
|
||||
);
|
||||
// Ensure that the one transaction with id is preserved, even though it is
|
||||
// a falsy id.
|
||||
assert.equal(newStorage.data.TransactionController.transactions[0].id, 0);
|
||||
expect(
|
||||
newStorage.data.TransactionController.transactions[0].id,
|
||||
).toStrictEqual(0);
|
||||
});
|
||||
|
||||
it('should not blow up if transactions are not an array', async function () {
|
||||
it('should not blow up if transactions are not an array', async () => {
|
||||
const storageWithTransactionsAsString = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -140,11 +137,13 @@ describe('migration #57', function () {
|
||||
storageWithTransactionsAsArrayOfString,
|
||||
);
|
||||
|
||||
assert.deepEqual(storageWithTransactionsAsString.data, result1.data);
|
||||
assert.deepEqual(storageWithTransactionsAsArrayOfString.data, result2.data);
|
||||
expect(storageWithTransactionsAsString.data).toStrictEqual(result1.data);
|
||||
expect(storageWithTransactionsAsArrayOfString.data).toStrictEqual(
|
||||
result2.data,
|
||||
);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state does not exist', async function () {
|
||||
it('should do nothing if transactions state does not exist', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -156,10 +155,10 @@ describe('migration #57', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration57.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should convert empty array into empty object', async function () {
|
||||
it('should convert empty array into empty object', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -172,7 +171,7 @@ describe('migration #57', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration57.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: {},
|
||||
bar: 'baz',
|
||||
@ -181,13 +180,13 @@ describe('migration #57', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should do nothing if state is empty', async function () {
|
||||
it('should do nothing if state is empty', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {},
|
||||
};
|
||||
|
||||
const newStorage = await migration57.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration58 from './058';
|
||||
|
||||
describe('migration #58', function () {
|
||||
@ -11,7 +10,7 @@ describe('migration #58', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration58.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 58,
|
||||
});
|
||||
});
|
||||
@ -29,7 +28,7 @@ describe('migration #58', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration58.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data.AppStateController, { bar: 'baz' });
|
||||
expect(newStorage.data.AppStateController).toStrictEqual({ bar: 'baz' });
|
||||
});
|
||||
|
||||
it('should not modify state if the AppStateController does not exist', async function () {
|
||||
@ -40,7 +39,7 @@ describe('migration #58', function () {
|
||||
},
|
||||
};
|
||||
const newStorage = await migration58.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, oldStorage.data);
|
||||
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import {
|
||||
KOVAN_CHAIN_ID,
|
||||
@ -133,7 +132,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 59,
|
||||
});
|
||||
});
|
||||
@ -152,7 +151,7 @@ describe('migration #59', function () {
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
const EXPECTED = cloneDeep(ERRONEOUS_TRANSACTION_STATE);
|
||||
delete EXPECTED['0'];
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: EXPECTED,
|
||||
},
|
||||
@ -184,7 +183,7 @@ describe('migration #59', function () {
|
||||
oldStorage.data.TransactionController.transactions,
|
||||
);
|
||||
delete EXPECTED['0'];
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: EXPECTED,
|
||||
},
|
||||
@ -211,7 +210,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: oldStorage.data.TransactionController.transactions,
|
||||
},
|
||||
@ -233,7 +232,7 @@ describe('migration #59', function () {
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
const EXPECTED = cloneDeep(ERRONEOUS_TRANSACTION_STATE_RETRY);
|
||||
delete EXPECTED['0'];
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: EXPECTED,
|
||||
},
|
||||
@ -265,7 +264,7 @@ describe('migration #59', function () {
|
||||
oldStorage.data.TransactionController.transactions,
|
||||
);
|
||||
delete EXPECTED['0'];
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: EXPECTED,
|
||||
},
|
||||
@ -292,7 +291,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: oldStorage.data.TransactionController.transactions,
|
||||
},
|
||||
@ -317,7 +316,7 @@ describe('migration #59', function () {
|
||||
// transactions we expect to be missing.
|
||||
const EXPECTED = cloneDeep(ERRONEOUS_TRANSACTION_STATE);
|
||||
delete EXPECTED['0'];
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TransactionController: {
|
||||
transactions: EXPECTED,
|
||||
},
|
||||
@ -340,7 +339,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state is empty', async function () {
|
||||
@ -356,7 +355,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if transactions state is not an object', async function () {
|
||||
@ -372,7 +371,7 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('should do nothing if state is empty', async function () {
|
||||
@ -382,6 +381,6 @@ describe('migration #59', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration59.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration60 from './060';
|
||||
|
||||
describe('migration #60', function () {
|
||||
@ -11,7 +10,7 @@ describe('migration #60', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 60,
|
||||
});
|
||||
});
|
||||
@ -56,10 +55,10 @@ describe('migration #60', function () {
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
const { notifications } = newStorage.data.NotificationController;
|
||||
const notificationKeys = Object.keys(notifications);
|
||||
// Assert support notification is removed
|
||||
assert.equal(notificationKeys.length, 3);
|
||||
// Expect support notification is removed
|
||||
expect(notificationKeys).toHaveLength(3);
|
||||
notificationKeys.forEach((key) => {
|
||||
assert.notEqual(notifications[key].date, '2020-08-31');
|
||||
expect(notifications[key].date).not.toStrictEqual('2020-08-31');
|
||||
});
|
||||
});
|
||||
|
||||
@ -97,7 +96,7 @@ describe('migration #60', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('does not modify state when NotificationsController is undefined', async function () {
|
||||
@ -110,7 +109,7 @@ describe('migration #60', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('does not modify state when notifications are undefined', async function () {
|
||||
@ -124,7 +123,7 @@ describe('migration #60', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
|
||||
it('does not modify state when notifications are not an object', async function () {
|
||||
@ -138,6 +137,6 @@ describe('migration #60', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration60.migrate(oldStorage);
|
||||
assert.deepEqual(oldStorage.data, newStorage.data);
|
||||
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import sinon from 'sinon';
|
||||
import migration61 from './061';
|
||||
|
||||
@ -22,7 +21,7 @@ describe('migration #61', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration61.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 61,
|
||||
});
|
||||
});
|
||||
@ -38,7 +37,7 @@ describe('migration #61', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration61.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
AppStateController: {
|
||||
recoveryPhraseReminderHasBeenShown: false,
|
||||
recoveryPhraseReminderLastShown: 1621580400000,
|
||||
@ -56,7 +55,7 @@ describe('migration #61', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration61.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
existingProperty: 'foo',
|
||||
AppStateController: {
|
||||
recoveryPhraseReminderHasBeenShown: false,
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration62 from './062';
|
||||
|
||||
describe('migration #62', function () {
|
||||
@ -11,7 +10,7 @@ describe('migration #62', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration62.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 62,
|
||||
});
|
||||
});
|
||||
@ -29,7 +28,7 @@ describe('migration #62', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration62.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
MetaMetricsController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -50,7 +49,7 @@ describe('migration #62', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration62.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
MetaMetricsController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
@ -70,7 +69,7 @@ describe('migration #62', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration62.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
MetaMetricsController: {
|
||||
bar: 'baz',
|
||||
},
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migration63 from './063';
|
||||
|
||||
describe('migration #63', function () {
|
||||
it('should update the version metadata', async function () {
|
||||
describe('migration #63', () => {
|
||||
it('should update the version metadata', async () => {
|
||||
const oldStorage = {
|
||||
meta: {
|
||||
version: 62,
|
||||
@ -11,12 +10,12 @@ describe('migration #63', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration63.migrate(oldStorage);
|
||||
assert.deepEqual(newStorage.meta, {
|
||||
expect(newStorage.meta).toStrictEqual({
|
||||
version: 63,
|
||||
});
|
||||
});
|
||||
|
||||
it('should move accountTokens data from PreferencesController to TokensController allTokens field and rotate structure from [accountAddress][chainId] to [chainId][accountAddress]', async function () {
|
||||
it('should move accountTokens data from PreferencesController to TokensController allTokens field and rotate structure from [accountAddress][chainId] to [chainId][accountAddress]', async () => {
|
||||
const oldAccountTokens = {
|
||||
'0x00000000000': {
|
||||
'0x1': [
|
||||
@ -155,7 +154,7 @@ describe('migration #63', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration63.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TokensController: {
|
||||
allTokens: expectedTokens,
|
||||
allIgnoredTokens: {},
|
||||
@ -167,7 +166,7 @@ describe('migration #63', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should move accountHiddenTokens data from PreferencesController to TokensController allIgnoredTokens field and rotate structure from [accountAddress][chainId] to [chainId][accountAddress]', async function () {
|
||||
it('should move accountHiddenTokens data from PreferencesController to TokensController allIgnoredTokens field and rotate structure from [accountAddress][chainId] to [chainId][accountAddress]', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -193,7 +192,7 @@ describe('migration #63', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration63.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
TokensController: {
|
||||
allTokens: {},
|
||||
allIgnoredTokens: {
|
||||
@ -219,7 +218,7 @@ describe('migration #63', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should should remove all token related state from the preferences controller', async function () {
|
||||
it('should should remove all token related state from the preferences controller', async () => {
|
||||
const oldStorage = {
|
||||
meta: {},
|
||||
data: {
|
||||
@ -237,7 +236,7 @@ describe('migration #63', function () {
|
||||
};
|
||||
|
||||
const newStorage = await migration63.migrate(oldStorage);
|
||||
assert.deepStrictEqual(newStorage.data, {
|
||||
expect(newStorage.data).toStrictEqual({
|
||||
PreferencesController: {
|
||||
completedOnboarding: true,
|
||||
dismissSeedBackUpReminder: false,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
/* eslint-disable jest/valid-expect-in-promise */
|
||||
import wallet1 from '../../../test/lib/migrations/001.json';
|
||||
import vault4 from '../../../test/lib/migrations/004.json';
|
||||
import migration2 from './002';
|
||||
@ -19,233 +19,140 @@ let vault5, vault6, vault7, vault8, vault9; // vault10, vault11
|
||||
const oldTestRpc = 'https://rawtestrpc.metamask.io/';
|
||||
const newTestRpc = 'https://testrpc.metamask.io/';
|
||||
|
||||
describe('wallet1 is migrated successfully', function () {
|
||||
it('should convert providers', function () {
|
||||
describe('wallet1 is migrated successfully', () => {
|
||||
it('should convert providers', () => {
|
||||
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null };
|
||||
|
||||
return migration2
|
||||
migration2
|
||||
.migrate(wallet1)
|
||||
.then((secondResult) => {
|
||||
const secondData = secondResult.data;
|
||||
assert.equal(
|
||||
secondData.config.provider.type,
|
||||
'rpc',
|
||||
'provider should be rpc',
|
||||
);
|
||||
assert.equal(
|
||||
secondData.config.provider.rpcTarget,
|
||||
expect(secondData.config.provider.type).toStrictEqual('rpc');
|
||||
expect(secondData.config.provider.rpcTarget).toStrictEqual(
|
||||
'https://rpc.metamask.io/',
|
||||
'main provider should be our rpc',
|
||||
);
|
||||
secondResult.data.config.provider.rpcTarget = oldTestRpc;
|
||||
return migration3.migrate(secondResult);
|
||||
})
|
||||
.then((thirdResult) => {
|
||||
assert.equal(
|
||||
thirdResult.data.config.provider.rpcTarget,
|
||||
expect(thirdResult.data.config.provider.rpcTarget).toStrictEqual(
|
||||
newTestRpc,
|
||||
'config.provider.rpcTarget should be set to the proper testrpc url.',
|
||||
);
|
||||
return migration4.migrate(thirdResult);
|
||||
})
|
||||
.then((fourthResult) => {
|
||||
const fourthData = fourthResult.data;
|
||||
assert.equal(
|
||||
fourthData.config.provider.rpcTarget,
|
||||
undefined,
|
||||
'old rpcTarget should not exist.',
|
||||
);
|
||||
assert.equal(
|
||||
fourthData.config.provider.type,
|
||||
'testnet',
|
||||
'config.provider should be set to testnet.',
|
||||
);
|
||||
expect(fourthData.config.provider.rpcTarget).toBeUndefined();
|
||||
expect(fourthData.config.provider.type).toStrictEqual('testnet');
|
||||
|
||||
return migration5.migrate(vault4);
|
||||
})
|
||||
.then((fifthResult) => {
|
||||
const fifthData = fifthResult.data;
|
||||
assert.equal(fifthData.vault, undefined, 'old vault should not exist');
|
||||
assert.equal(
|
||||
fifthData.walletNicknames,
|
||||
undefined,
|
||||
'old walletNicknames should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
fifthData.config.selectedAccount,
|
||||
undefined,
|
||||
'old config.selectedAccount should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
fifthData.KeyringController.vault,
|
||||
expect(fifthData.vault).toBeUndefined();
|
||||
expect(fifthData.walletNicknames).toBeUndefined();
|
||||
expect(fifthData.config.selectedAccount).toBeUndefined();
|
||||
expect(fifthData.KeyringController.vault).toStrictEqual(
|
||||
vault4.data.vault,
|
||||
'KeyringController.vault should exist',
|
||||
);
|
||||
assert.equal(
|
||||
fifthData.KeyringController.selectedAccount,
|
||||
expect(fifthData.KeyringController.selectedAccount).toStrictEqual(
|
||||
vault4.data.config.selectedAccount,
|
||||
'KeyringController.selectedAccount should have moved',
|
||||
);
|
||||
assert.equal(
|
||||
expect(
|
||||
fifthData.KeyringController.walletNicknames[
|
||||
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
||||
],
|
||||
).toStrictEqual(
|
||||
vault4.data.walletNicknames[
|
||||
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
||||
],
|
||||
'KeyringController.walletNicknames should have moved',
|
||||
);
|
||||
|
||||
vault5 = fifthResult;
|
||||
return migration6.migrate(fifthResult);
|
||||
})
|
||||
.then((sixthResult) => {
|
||||
assert.equal(
|
||||
expect(
|
||||
sixthResult.data.KeyringController.selectedAccount,
|
||||
undefined,
|
||||
'old selectedAccount should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
sixthResult.data.PreferencesController.selectedAddress,
|
||||
vault5.data.KeyringController.selectedAccount,
|
||||
'selectedAccount should have moved',
|
||||
);
|
||||
).toStrictEqual(vault5.data.KeyringController.selectedAccount);
|
||||
|
||||
vault6 = sixthResult;
|
||||
return migration7.migrate(sixthResult);
|
||||
})
|
||||
.then((seventhResult) => {
|
||||
assert.equal(
|
||||
seventhResult.data.transactions,
|
||||
undefined,
|
||||
'old transactions should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
seventhResult.data.gasMultiplier,
|
||||
undefined,
|
||||
'old gasMultiplier should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
expect(seventhResult.data.transactions).toBeUndefined();
|
||||
expect(seventhResult.data.gasMultiplier).toBeUndefined();
|
||||
expect(
|
||||
seventhResult.data.TransactionManager.transactions[0].id,
|
||||
vault6.data.transactions[0].id,
|
||||
'transactions should have moved',
|
||||
);
|
||||
assert.equal(
|
||||
).toStrictEqual(vault6.data.transactions[0].id);
|
||||
expect(
|
||||
seventhResult.data.TransactionManager.gasMultiplier,
|
||||
vault6.data.gasMultiplier,
|
||||
'gasMultiplier should have moved',
|
||||
);
|
||||
).toStrictEqual(vault6.data.gasMultiplier);
|
||||
|
||||
vault7 = seventhResult;
|
||||
return migration8.migrate(seventhResult);
|
||||
})
|
||||
.then((eighthResult) => {
|
||||
assert.equal(
|
||||
eighthResult.data.noticesList,
|
||||
undefined,
|
||||
'old noticesList should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
expect(eighthResult.data.noticesList).toBeUndefined();
|
||||
expect(
|
||||
eighthResult.data.NoticeController.noticesList[0].title,
|
||||
vault7.data.noticesList[0].title,
|
||||
'noticesList should have moved',
|
||||
);
|
||||
).toStrictEqual(vault7.data.noticesList[0].title);
|
||||
|
||||
vault8 = eighthResult;
|
||||
return migration9.migrate(eighthResult);
|
||||
})
|
||||
.then((ninthResult) => {
|
||||
assert.equal(
|
||||
ninthResult.data.currentFiat,
|
||||
undefined,
|
||||
'old currentFiat should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
ninthResult.data.fiatCurrency,
|
||||
undefined,
|
||||
'old fiatCurrency should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
ninthResult.data.conversionRate,
|
||||
undefined,
|
||||
'old conversionRate should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
ninthResult.data.conversionDate,
|
||||
undefined,
|
||||
'old conversionDate should not exist',
|
||||
);
|
||||
expect(ninthResult.data.currentFiat).toBeUndefined();
|
||||
expect(ninthResult.data.fiatCurrency).toBeUndefined();
|
||||
expect(ninthResult.data.conversionRate).toBeUndefined();
|
||||
expect(ninthResult.data.conversionDate).toBeUndefined();
|
||||
|
||||
assert.equal(
|
||||
expect(
|
||||
ninthResult.data.CurrencyController.currentCurrency,
|
||||
vault8.data.fiatCurrency,
|
||||
'currentFiat should have moved',
|
||||
);
|
||||
assert.equal(
|
||||
).toStrictEqual(vault8.data.fiatCurrency);
|
||||
expect(
|
||||
ninthResult.data.CurrencyController.conversionRate,
|
||||
vault8.data.conversionRate,
|
||||
'conversionRate should have moved',
|
||||
);
|
||||
assert.equal(
|
||||
).toStrictEqual(vault8.data.conversionRate);
|
||||
expect(
|
||||
ninthResult.data.CurrencyController.conversionDate,
|
||||
vault8.data.conversionDate,
|
||||
'conversionDate should have moved',
|
||||
);
|
||||
).toStrictEqual(vault8.data.conversionDate);
|
||||
|
||||
vault9 = ninthResult;
|
||||
return migration10.migrate(ninthResult);
|
||||
})
|
||||
.then((tenthResult) => {
|
||||
assert.equal(
|
||||
tenthResult.data.shapeShiftTxList,
|
||||
undefined,
|
||||
'old shapeShiftTxList should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
expect(tenthResult.data.shapeShiftTxList).toBeUndefined();
|
||||
expect(
|
||||
tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction,
|
||||
vault9.data.shapeShiftTxList[0].transaction,
|
||||
);
|
||||
).toStrictEqual(vault9.data.shapeShiftTxList[0].transaction);
|
||||
|
||||
return migration11.migrate(tenthResult);
|
||||
})
|
||||
.then((eleventhResult) => {
|
||||
assert.equal(
|
||||
eleventhResult.data.isDisclaimerConfirmed,
|
||||
undefined,
|
||||
'isDisclaimerConfirmed should not exist',
|
||||
);
|
||||
assert.equal(
|
||||
eleventhResult.data.TOSHash,
|
||||
undefined,
|
||||
'TOSHash should not exist',
|
||||
);
|
||||
expect(eleventhResult.data.isDisclaimerConfirmed).toBeUndefined();
|
||||
expect(eleventhResult.data.TOSHash).toBeUndefined();
|
||||
|
||||
return migration12.migrate(eleventhResult);
|
||||
})
|
||||
.then((twelfthResult) => {
|
||||
assert.equal(
|
||||
expect(
|
||||
twelfthResult.data.NoticeController.noticesList[0].body,
|
||||
'',
|
||||
'notices that have been read should have an empty body.',
|
||||
);
|
||||
assert.equal(
|
||||
).toStrictEqual('');
|
||||
expect(
|
||||
twelfthResult.data.NoticeController.noticesList[1].body,
|
||||
'nonempty',
|
||||
'notices that have not been read should not have an empty body.',
|
||||
);
|
||||
).toStrictEqual('nonempty');
|
||||
|
||||
assert.equal(
|
||||
twelfthResult.data.config.provider.type,
|
||||
expect(twelfthResult.data.config.provider.type).toStrictEqual(
|
||||
'testnet',
|
||||
'network is originally testnet.',
|
||||
);
|
||||
return migration13.migrate(twelfthResult);
|
||||
})
|
||||
.then((thirteenthResult) => {
|
||||
assert.equal(
|
||||
thirteenthResult.data.config.provider.type,
|
||||
expect(thirteenthResult.data.config.provider.type).toStrictEqual(
|
||||
'ropsten',
|
||||
'network has been changed to ropsten.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import migrationTemplate from './template';
|
||||
|
||||
const storage = {
|
||||
@ -6,14 +5,9 @@ const storage = {
|
||||
data: {},
|
||||
};
|
||||
|
||||
describe('storage is migrated successfully', function () {
|
||||
it('should work', function (done) {
|
||||
migrationTemplate
|
||||
.migrate(storage)
|
||||
.then((migratedData) => {
|
||||
assert.equal(migratedData.meta.version, 0);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
describe('storage is migrated successfully', () => {
|
||||
it('should work', async () => {
|
||||
const migratedData = await migrationTemplate.migrate(storage);
|
||||
expect(migratedData.meta.version).toStrictEqual(0);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,4 @@
|
||||
module.exports = {
|
||||
displayName: '/ui, /shared',
|
||||
collectCoverageFrom: ['<rootDir>/ui/**/*.js', '<rootDir>/shared/**/*.js'],
|
||||
coverageDirectory: './jest-coverage/main',
|
||||
coveragePathIgnorePatterns: ['.stories.js', '.snap'],
|
||||
@ -17,6 +16,10 @@ module.exports = {
|
||||
restoreMocks: true,
|
||||
setupFiles: ['<rootDir>/test/setup.js', '<rootDir>/test/env.js'],
|
||||
setupFilesAfterEnv: ['<rootDir>/test/jest/setup.js'],
|
||||
testMatch: ['<rootDir>/ui/**/*.test.js', '<rootDir>/shared/**/*.test.js'],
|
||||
testMatch: [
|
||||
'<rootDir>/ui/**/*.test.js',
|
||||
'<rootDir>/shared/**/*.test.js',
|
||||
'<rootDir>/app/scripts/migrations/*.test.js',
|
||||
],
|
||||
testTimeout: 2500,
|
||||
};
|
||||
|
@ -27,7 +27,7 @@
|
||||
"test:unit": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/**/*.test.js'",
|
||||
"test:unit:global": "mocha --exit --require test/env.js --require test/setup.js --recursive test/unit-global/*.test.js",
|
||||
"test:unit:jest": "./test/run-jest.sh",
|
||||
"test:unit:lax": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/controllers/permissions/*.test.js' --recursive './app/**/*.test.js'",
|
||||
"test:unit:lax": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/controllers/permissions/*.test.js' --ignore './app/scripts/migrations/*.test.js' --recursive './app/**/*.test.js'",
|
||||
"test:unit:strict": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/scripts/controllers/permissions/*.test.js'",
|
||||
"test:unit:path": "mocha --exit --require test/env.js --require test/setup.js --recursive",
|
||||
"test:e2e:chrome": "SELENIUM_BROWSER=chrome node test/e2e/run-all.js",
|
||||
|
@ -4,6 +4,8 @@ import Adapter from 'enzyme-adapter-react-16';
|
||||
import log from 'loglevel';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
process.env.IN_TEST = true;
|
||||
|
||||
nock.disableNetConnect();
|
||||
nock.enableNetConnect('localhost');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user