2021-09-21 18:28:13 +02:00
|
|
|
/* eslint-disable jest/valid-expect-in-promise */
|
2021-03-16 22:00:08 +01:00
|
|
|
import wallet1 from '../../../test/lib/migrations/001.json';
|
|
|
|
import vault4 from '../../../test/lib/migrations/004.json';
|
|
|
|
import migration2 from './002';
|
|
|
|
import migration3 from './003';
|
|
|
|
import migration4 from './004';
|
|
|
|
import migration5 from './005';
|
|
|
|
import migration6 from './006';
|
|
|
|
import migration7 from './007';
|
|
|
|
import migration8 from './008';
|
|
|
|
import migration9 from './009';
|
|
|
|
import migration10 from './010';
|
|
|
|
import migration11 from './011';
|
|
|
|
import migration12 from './012';
|
|
|
|
import migration13 from './013';
|
2016-04-12 23:16:39 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
let vault5, vault6, vault7, vault8, vault9; // vault10, vault11
|
2016-04-22 22:59:42 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const oldTestRpc = 'https://rawtestrpc.metamask.io/';
|
|
|
|
const newTestRpc = 'https://testrpc.metamask.io/';
|
2016-04-12 23:16:39 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('wallet1 is migrated successfully', () => {
|
|
|
|
it('should convert providers', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null };
|
2016-04-22 22:32:56 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
migration2
|
2020-11-03 00:41:28 +01:00
|
|
|
.migrate(wallet1)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((secondResult) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const secondData = secondResult.data;
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(secondData.config.provider.type).toStrictEqual('rpc');
|
|
|
|
expect(secondData.config.provider.rpcTarget).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
'https://rpc.metamask.io/',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
secondResult.data.config.provider.rpcTarget = oldTestRpc;
|
|
|
|
return migration3.migrate(secondResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((thirdResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(thirdResult.data.config.provider.rpcTarget).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
newTestRpc,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return migration4.migrate(thirdResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((fourthResult) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const fourthData = fourthResult.data;
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(fourthData.config.provider.rpcTarget).toBeUndefined();
|
|
|
|
expect(fourthData.config.provider.type).toStrictEqual('testnet');
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return migration5.migrate(vault4);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((fifthResult) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const fifthData = fifthResult.data;
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(fifthData.vault).toBeUndefined();
|
|
|
|
expect(fifthData.walletNicknames).toBeUndefined();
|
|
|
|
expect(fifthData.config.selectedAccount).toBeUndefined();
|
|
|
|
expect(fifthData.KeyringController.vault).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
vault4.data.vault,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(fifthData.KeyringController.selectedAccount).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
vault4.data.config.selectedAccount,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
fifthData.KeyringController.walletNicknames[
|
|
|
|
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
|
|
|
],
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
vault4.data.walletNicknames[
|
|
|
|
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
|
|
|
],
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
vault5 = fifthResult;
|
|
|
|
return migration6.migrate(fifthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((sixthResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
sixthResult.data.KeyringController.selectedAccount,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toBeUndefined();
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
sixthResult.data.PreferencesController.selectedAddress,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault5.data.KeyringController.selectedAccount);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
vault6 = sixthResult;
|
|
|
|
return migration7.migrate(sixthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((seventhResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(seventhResult.data.transactions).toBeUndefined();
|
|
|
|
expect(seventhResult.data.gasMultiplier).toBeUndefined();
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
seventhResult.data.TransactionManager.transactions[0].id,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault6.data.transactions[0].id);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
seventhResult.data.TransactionManager.gasMultiplier,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault6.data.gasMultiplier);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
vault7 = seventhResult;
|
|
|
|
return migration8.migrate(seventhResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((eighthResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(eighthResult.data.noticesList).toBeUndefined();
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
eighthResult.data.NoticeController.noticesList[0].title,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault7.data.noticesList[0].title);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
vault8 = eighthResult;
|
|
|
|
return migration9.migrate(eighthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((ninthResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(ninthResult.data.currentFiat).toBeUndefined();
|
|
|
|
expect(ninthResult.data.fiatCurrency).toBeUndefined();
|
|
|
|
expect(ninthResult.data.conversionRate).toBeUndefined();
|
|
|
|
expect(ninthResult.data.conversionDate).toBeUndefined();
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
ninthResult.data.CurrencyController.currentCurrency,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault8.data.fiatCurrency);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
ninthResult.data.CurrencyController.conversionRate,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault8.data.conversionRate);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
ninthResult.data.CurrencyController.conversionDate,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault8.data.conversionDate);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
vault9 = ninthResult;
|
|
|
|
return migration10.migrate(ninthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((tenthResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(tenthResult.data.shapeShiftTxList).toBeUndefined();
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual(vault9.data.shapeShiftTxList[0].transaction);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return migration11.migrate(tenthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((eleventhResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(eleventhResult.data.isDisclaimerConfirmed).toBeUndefined();
|
|
|
|
expect(eleventhResult.data.TOSHash).toBeUndefined();
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return migration12.migrate(eleventhResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((twelfthResult) => {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
twelfthResult.data.NoticeController.noticesList[0].body,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual('');
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
twelfthResult.data.NoticeController.noticesList[1].body,
|
2021-09-21 18:28:13 +02:00
|
|
|
).toStrictEqual('nonempty');
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(twelfthResult.data.config.provider.type).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
'testnet',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return migration13.migrate(twelfthResult);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|