2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
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
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('wallet1 is migrated successfully', function () {
|
|
|
|
it('should convert providers', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null };
|
2016-04-22 22:32:56 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
return migration2
|
|
|
|
.migrate(wallet1)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((secondResult) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const secondData = secondResult.data;
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
secondData.config.provider.type,
|
|
|
|
'rpc',
|
|
|
|
'provider should be rpc',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
secondData.config.provider.rpcTarget,
|
|
|
|
'https://rpc.metamask.io/',
|
|
|
|
'main provider should be our rpc',
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
thirdResult.data.config.provider.rpcTarget,
|
|
|
|
newTestRpc,
|
|
|
|
'config.provider.rpcTarget should be set to the proper testrpc url.',
|
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;
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fourthData.config.provider.rpcTarget,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old rpcTarget should not exist.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fourthData.config.provider.type,
|
|
|
|
'testnet',
|
|
|
|
'config.provider should be set to testnet.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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-05-07 21:38:24 +02:00
|
|
|
assert.equal(fifthData.vault, undefined, 'old vault should not exist');
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fifthData.walletNicknames,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old walletNicknames should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fifthData.config.selectedAccount,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old config.selectedAccount should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fifthData.KeyringController.vault,
|
|
|
|
vault4.data.vault,
|
|
|
|
'KeyringController.vault should exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fifthData.KeyringController.selectedAccount,
|
|
|
|
vault4.data.config.selectedAccount,
|
|
|
|
'KeyringController.selectedAccount should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
fifthData.KeyringController.walletNicknames[
|
|
|
|
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
|
|
|
],
|
|
|
|
vault4.data.walletNicknames[
|
|
|
|
'0x0beb674745816b125fbc07285d39fd373e64895c'
|
|
|
|
],
|
|
|
|
'KeyringController.walletNicknames should have moved',
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
sixthResult.data.KeyringController.selectedAccount,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old selectedAccount should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
sixthResult.data.PreferencesController.selectedAddress,
|
|
|
|
vault5.data.KeyringController.selectedAccount,
|
|
|
|
'selectedAccount should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
seventhResult.data.transactions,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old transactions should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
seventhResult.data.gasMultiplier,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old gasMultiplier should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
seventhResult.data.TransactionManager.transactions[0].id,
|
|
|
|
vault6.data.transactions[0].id,
|
|
|
|
'transactions should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
seventhResult.data.TransactionManager.gasMultiplier,
|
|
|
|
vault6.data.gasMultiplier,
|
|
|
|
'gasMultiplier should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
eighthResult.data.noticesList,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old noticesList should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
eighthResult.data.NoticeController.noticesList[0].title,
|
|
|
|
vault7.data.noticesList[0].title,
|
|
|
|
'noticesList should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.currentFiat,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old currentFiat should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.fiatCurrency,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old fiatCurrency should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.conversionRate,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old conversionRate should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.conversionDate,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old conversionDate should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.CurrencyController.currentCurrency,
|
|
|
|
vault8.data.fiatCurrency,
|
|
|
|
'currentFiat should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.CurrencyController.conversionRate,
|
|
|
|
vault8.data.conversionRate,
|
|
|
|
'conversionRate should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
ninthResult.data.CurrencyController.conversionDate,
|
|
|
|
vault8.data.conversionDate,
|
|
|
|
'conversionDate should have moved',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
tenthResult.data.shapeShiftTxList,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'old shapeShiftTxList should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction,
|
|
|
|
vault9.data.shapeShiftTxList[0].transaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
eleventhResult.data.isDisclaimerConfirmed,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'isDisclaimerConfirmed should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
eleventhResult.data.TOSHash,
|
2021-05-07 21:38:24 +02:00
|
|
|
undefined,
|
2020-11-03 00:41:28 +01:00
|
|
|
'TOSHash should not exist',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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) => {
|
|
|
|
assert.equal(
|
|
|
|
twelfthResult.data.NoticeController.noticesList[0].body,
|
|
|
|
'',
|
|
|
|
'notices that have been read should have an empty body.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
twelfthResult.data.NoticeController.noticesList[1].body,
|
|
|
|
'nonempty',
|
|
|
|
'notices that have not been read should not have an empty body.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
twelfthResult.data.config.provider.type,
|
|
|
|
'testnet',
|
|
|
|
'network is originally testnet.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
return migration13.migrate(twelfthResult);
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.then((thirteenthResult) => {
|
|
|
|
assert.equal(
|
|
|
|
thirteenthResult.data.config.provider.type,
|
|
|
|
'ropsten',
|
|
|
|
'network has been changed to ropsten.',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|