2022-09-14 16:55:31 +02:00
|
|
|
import { CHAIN_IDS, NETWORK_TYPES } from '../../../shared/constants/network';
|
2021-03-19 22:54:30 +01:00
|
|
|
import migration55 from './055';
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #55', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2021-03-19 22:54:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {
|
|
|
|
version: 54,
|
|
|
|
},
|
|
|
|
data: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration55.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2021-03-19 22:54:30 +01:00
|
|
|
version: 55,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should replace incomingTxLastFetchedBlocksByNetwork with incomingTxLastFetchedBlockByChainId, and carry over old values', async () => {
|
2021-03-19 22:54:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
IncomingTransactionsController: {
|
|
|
|
incomingTransactions: {
|
|
|
|
test: {
|
|
|
|
transactionCategory: 'incoming',
|
|
|
|
txParams: {
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
incomingTxLastFetchedBlocksByNetwork: {
|
2022-09-14 16:55:31 +02:00
|
|
|
[NETWORK_TYPES.MAINNET]: 1,
|
|
|
|
[NETWORK_TYPES.ROPSTEN]: 2,
|
|
|
|
[NETWORK_TYPES.RINKEBY]: 3,
|
|
|
|
[NETWORK_TYPES.GOERLI]: 4,
|
|
|
|
[NETWORK_TYPES.KOVAN]: 5,
|
2021-03-19 22:54:30 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration55.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 22:54:30 +01:00
|
|
|
IncomingTransactionsController: {
|
|
|
|
incomingTransactions:
|
|
|
|
oldStorage.data.IncomingTransactionsController.incomingTransactions,
|
|
|
|
incomingTxLastFetchedBlockByChainId: {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: 1,
|
|
|
|
[CHAIN_IDS.ROPSTEN]: 2,
|
|
|
|
[CHAIN_IDS.RINKEBY]: 3,
|
|
|
|
[CHAIN_IDS.GOERLI]: 4,
|
|
|
|
[CHAIN_IDS.KOVAN]: 5,
|
2021-03-19 22:54:30 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if incomingTxLastFetchedBlocksByNetwork key is not populated', async () => {
|
2021-03-19 22:54:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
IncomingTransactionsController: {
|
|
|
|
foo: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration55.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
2021-03-19 22:54:30 +01:00
|
|
|
});
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if state is empty', async () => {
|
2021-03-19 22:54:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration55.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
2021-03-19 22:54:30 +01:00
|
|
|
});
|
|
|
|
});
|