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,
|
2022-09-29 05:26:01 +02:00
|
|
|
ropsten: 2,
|
|
|
|
rinkeby: 3,
|
2022-09-14 16:55:31 +02:00
|
|
|
[NETWORK_TYPES.GOERLI]: 4,
|
2022-09-29 05:26:01 +02:00
|
|
|
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,
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': 2,
|
|
|
|
'0x4': 3,
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.GOERLI]: 4,
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x2a': 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
|
|
|
});
|
|
|
|
});
|