2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import data from '../first-time-state';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { TRANSACTION_STATUSES } 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' },
|
2020-11-07 08:38:12 +01:00
|
|
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-03 00:41:28 +01:00
|
|
|
transactions.push({
|
|
|
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
2020-11-07 08:38:12 +01:00
|
|
|
status: TRANSACTION_STATUSES.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
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
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)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((migratedData) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const migratedTransactions =
|
2021-02-04 19:15:23 +01:00
|
|
|
migratedData.data.TransactionController.transactions;
|
2019-07-31 22:17:11 +02:00
|
|
|
migratedTransactions.forEach((tx) => {
|
2020-11-07 08:38:12 +01:00
|
|
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
tx.txParams.from,
|
|
|
|
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-20 01:03:20 +01:00
|
|
|
} else {
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
tx.txParams.from,
|
|
|
|
'0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-20 01:03:20 +01:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2018-04-05 20:28:25 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should migrate first time state', function (done) {
|
2020-11-03 00:41:28 +01:00
|
|
|
migration24
|
|
|
|
.migrate(firstTimeState)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((migratedData) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.equal(migratedData.meta.version, 24);
|
|
|
|
done();
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|