2021-02-04 19:15:23 +01:00
|
|
|
import assert from 'assert';
|
|
|
|
import migration22 from '../../../app/scripts/migrations/022';
|
|
|
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const properTime = new Date().getTime();
|
2018-03-26 23:24:12 +02:00
|
|
|
const storage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
TransactionController: {
|
|
|
|
transactions: [
|
2020-11-07 08:38:12 +01:00
|
|
|
{ status: TRANSACTION_STATUSES.SUBMITTED },
|
|
|
|
{ status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: properTime },
|
|
|
|
{ status: TRANSACTION_STATUSES.CONFIRMED },
|
2018-07-03 00:49:33 +02:00
|
|
|
],
|
2018-03-26 23:24:12 +02:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-03-26 23:24:12 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
|
|
|
it('should add submittedTime key on the txMeta if appropriate', function (done) {
|
2020-11-03 00:41:28 +01:00
|
|
|
migration22
|
|
|
|
.migrate(storage)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((migratedData) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const [
|
|
|
|
txMeta1,
|
|
|
|
txMeta2,
|
|
|
|
txMeta3,
|
2021-02-04 19:15:23 +01:00
|
|
|
] = migratedData.data.TransactionController.transactions;
|
|
|
|
assert.equal(migratedData.meta.version, 22);
|
2019-07-31 22:17:11 +02:00
|
|
|
// should have written a submitted time
|
2021-02-04 19:15:23 +01:00
|
|
|
assert(txMeta1.submittedTime);
|
2019-07-31 22:17:11 +02:00
|
|
|
// should not have written a submitted time because it already has one
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.equal(txMeta2.submittedTime, properTime);
|
2019-07-31 22:17:11 +02:00
|
|
|
// should not have written a submitted time
|
2021-02-04 19:15:23 +01:00
|
|
|
assert(!txMeta3.submittedTime);
|
|
|
|
done();
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|