1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/migrations/025.test.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

/* eslint-disable jest/no-conditional-expect */
import data from '../first-time-state';
import { TransactionStatus } from '../../../shared/constants/transaction';
import migration25 from './025';
2018-04-06 03:05:03 +02:00
const firstTimeState = {
meta: {},
data,
};
2018-04-06 03:05:03 +02:00
const storage = {
2020-11-03 00:41:28 +01:00
meta: {},
data: {
TransactionController: {
transactions: [],
2018-04-06 03:05:03 +02:00
},
},
};
2018-04-06 03:05:03 +02:00
const transactions = [];
2018-04-06 03:05:03 +02:00
while (transactions.length <= 10) {
2020-11-03 00:41:28 +01:00
transactions.push({
txParams: {
from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
random: 'stuff',
chainId: 2,
},
status: TransactionStatus.unapproved,
});
2020-11-03 00:41:28 +01:00
transactions.push({
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
status: TransactionStatus.confirmed,
});
2018-04-06 03:05:03 +02:00
}
storage.data.TransactionController.transactions = transactions;
2018-04-06 03:05:03 +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 migration25.migrate(storage);
const migratedTransactions =
migratedData.data.TransactionController.transactions;
migratedTransactions.forEach((tx) => {
if (tx.status === TransactionStatus.unapproved) {
expect(!tx.txParams.random).toStrictEqual(true);
}
if (tx.status === TransactionStatus.unapproved) {
expect(!tx.txParams.chainId).toStrictEqual(true);
}
});
});
2018-04-06 03:05:03 +02:00
it('should migrate first time state', async () => {
const migratedData = await migration25.migrate(firstTimeState);
expect(migratedData.meta.version).toStrictEqual(25);
});
});