1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 20:57:12 +01:00
metamask-extension/app/scripts/migrations/055.test.js
ryanml 0bc1eeaf37
Deprecating the Rinkeby, Ropsten, and Kovan test networks (#15989)
* Deprecating Rinkeby, setting default debug network to Goerli

* Deprecating Ropsten and Kovan

* Conflict fix

* Remove unused localization, test fixes

* Add migration for moving used deprecated testnets to custom networks

* Fix migrator test

* Add more unit tests

* Migration updates provider type to rpc if deprecated network is selected

* Migration fully and correctly updates the provider if selected network is a deprecated testnet

* Continue to show deprecation warning on each of rinkeby, ropsten and kovan

* Add rpcUrl deprecation message to loading screen

* Removing mayBeFauceting prop

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2022-09-28 20:26:01 -07:00

85 lines
2.2 KiB
JavaScript

import { CHAIN_IDS, NETWORK_TYPES } from '../../../shared/constants/network';
import migration55 from './055';
describe('migration #55', () => {
it('should update the version metadata', async () => {
const oldStorage = {
meta: {
version: 54,
},
data: {},
};
const newStorage = await migration55.migrate(oldStorage);
expect(newStorage.meta).toStrictEqual({
version: 55,
});
});
it('should replace incomingTxLastFetchedBlocksByNetwork with incomingTxLastFetchedBlockByChainId, and carry over old values', async () => {
const oldStorage = {
meta: {},
data: {
IncomingTransactionsController: {
incomingTransactions: {
test: {
transactionCategory: 'incoming',
txParams: {
foo: 'bar',
},
},
},
incomingTxLastFetchedBlocksByNetwork: {
[NETWORK_TYPES.MAINNET]: 1,
ropsten: 2,
rinkeby: 3,
[NETWORK_TYPES.GOERLI]: 4,
kovan: 5,
},
},
foo: 'bar',
},
};
const newStorage = await migration55.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
IncomingTransactionsController: {
incomingTransactions:
oldStorage.data.IncomingTransactionsController.incomingTransactions,
incomingTxLastFetchedBlockByChainId: {
[CHAIN_IDS.MAINNET]: 1,
'0x3': 2,
'0x4': 3,
[CHAIN_IDS.GOERLI]: 4,
'0x2a': 5,
},
},
foo: 'bar',
});
});
it('should do nothing if incomingTxLastFetchedBlocksByNetwork key is not populated', async () => {
const oldStorage = {
meta: {},
data: {
IncomingTransactionsController: {
foo: 'baz',
},
foo: 'bar',
},
};
const newStorage = await migration55.migrate(oldStorage);
expect(oldStorage.data).toStrictEqual(newStorage.data);
});
it('should do nothing if state is empty', async () => {
const oldStorage = {
meta: {},
data: {},
};
const newStorage = await migration55.migrate(oldStorage);
expect(oldStorage.data).toStrictEqual(newStorage.data);
});
});