2021-09-21 18:28:13 +02:00
|
|
|
/* eslint-disable jest/no-conditional-expect */
|
2021-03-16 22:00:08 +01:00
|
|
|
import data from '../first-time-state';
|
2023-01-18 15:47:29 +01:00
|
|
|
import { TransactionStatus } from '../../../shared/constants/transaction';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration24 from './024';
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2018-04-05 20:28:25 +02:00
|
|
|
const firstTimeState = {
|
|
|
|
meta: {},
|
2020-01-09 04:34:58 +01:00
|
|
|
data,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-04-04 23:22:46 +02:00
|
|
|
const storage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
TransactionController: {
|
|
|
|
transactions: [],
|
2018-04-04 23:22:46 +02:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-04-04 23:22:46 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const transactions = [];
|
2018-04-04 23:22:46 +02:00
|
|
|
|
|
|
|
while (transactions.length <= 10) {
|
2020-11-03 00:41:28 +01:00
|
|
|
transactions.push({
|
|
|
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
2023-01-18 15:47:29 +01:00
|
|
|
status: TransactionStatus.unapproved,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-03 00:41:28 +01:00
|
|
|
transactions.push({
|
|
|
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
2023-01-18 15:47:29 +01:00
|
|
|
status: TransactionStatus.confirmed,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-04-04 23:22:46 +02:00
|
|
|
}
|
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
storage.data.TransactionController.transactions = transactions;
|
2018-04-04 23:22:46 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
|
|
|
it('should lowercase the from for unapproved txs', async () => {
|
|
|
|
const migratedData = await migration24.migrate(storage);
|
|
|
|
const migratedTransactions =
|
|
|
|
migratedData.data.TransactionController.transactions;
|
|
|
|
|
|
|
|
migratedTransactions.forEach((tx) => {
|
2023-01-18 15:47:29 +01:00
|
|
|
if (tx.status === TransactionStatus.unapproved) {
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(tx.txParams.from).toStrictEqual(
|
|
|
|
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
expect(tx.txParams.from).toStrictEqual(
|
|
|
|
'0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-04-05 20:28:25 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should migrate first time state', async () => {
|
|
|
|
const migratedData = await migration24.migrate(firstTimeState);
|
|
|
|
expect(migratedData.meta.version).toStrictEqual(24);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|