1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/app/scripts/migrations/024.test.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

import { strict as assert } from 'assert';
import data from '../first-time-state';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
import migration24 from './024';
const firstTimeState = {
meta: {},
data,
};
const storage = {
2020-11-03 00:41:28 +01:00
meta: {},
data: {
TransactionController: {
transactions: [],
},
},
};
const transactions = [];
while (transactions.length <= 10) {
2020-11-03 00:41:28 +01:00
transactions.push({
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
status: TRANSACTION_STATUSES.UNAPPROVED,
});
2020-11-03 00:41:28 +01:00
transactions.push({
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
status: TRANSACTION_STATUSES.CONFIRMED,
});
}
storage.data.TransactionController.transactions = transactions;
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
it('should lowercase the from for unapproved txs', function (done) {
2020-11-03 00:41:28 +01:00
migration24
.migrate(storage)
.then((migratedData) => {
2020-11-03 00:41:28 +01:00
const migratedTransactions =
migratedData.data.TransactionController.transactions;
migratedTransactions.forEach((tx) => {
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
2020-11-03 00:41:28 +01:00
assert.equal(
tx.txParams.from,
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
);
} else {
2020-11-03 00:41:28 +01:00
assert.equal(
tx.txParams.from,
'0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
);
}
});
done();
2020-11-03 00:41:28 +01:00
})
.catch(done);
});
it('should migrate first time state', function (done) {
2020-11-03 00:41:28 +01:00
migration24
.migrate(firstTimeState)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 24);
done();
2020-11-03 00:41:28 +01:00
})
.catch(done);
});
});