You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.8 KiB
68 lines
1.8 KiB
4 years ago
|
import assert from 'assert';
|
||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||
4 years ago
|
import migration29 from './029';
|
||
5 years ago
|
|
||
4 years ago
|
const properTime = new Date().getTime();
|
||
6 years ago
|
const storage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
TransactionController: {
|
||
|
transactions: [
|
||
4 years ago
|
{ status: TRANSACTION_STATUSES.APPROVED, id: 1, submittedTime: 0 },
|
||
|
{
|
||
|
status: TRANSACTION_STATUSES.APPROVED,
|
||
|
id: 2,
|
||
|
submittedTime: properTime,
|
||
|
},
|
||
|
{
|
||
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
|
id: 3,
|
||
|
submittedTime: properTime,
|
||
|
},
|
||
|
{
|
||
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
|
id: 4,
|
||
|
submittedTime: properTime,
|
||
|
},
|
||
|
{ status: TRANSACTION_STATUSES.SUBMITTED, id: 5, submittedTime: 0 },
|
||
6 years ago
|
],
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
5 years ago
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||
|
it('should auto fail transactions more than 12 hours old', function (done) {
|
||
4 years ago
|
migration29
|
||
|
.migrate(storage)
|
||
5 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
const txs = migratedData.data.TransactionController.transactions;
|
||
|
const [txMeta1] = txs;
|
||
|
assert.equal(migratedData.meta.version, 29);
|
||
6 years ago
|
|
||
4 years ago
|
assert.equal(
|
||
|
txMeta1.status,
|
||
|
TRANSACTION_STATUSES.FAILED,
|
||
|
'old tx is auto failed',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert(
|
||
|
txMeta1.err.message.includes('too long'),
|
||
|
'error message assigned',
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
5 years ago
|
txs.forEach((tx) => {
|
||
5 years ago
|
if (tx.id === 1) {
|
||
4 years ago
|
return;
|
||
5 years ago
|
}
|
||
4 years ago
|
assert.notEqual(
|
||
|
tx.status,
|
||
|
TRANSACTION_STATUSES.FAILED,
|
||
|
'other tx is not auto failed',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|