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.
69 lines
1.7 KiB
69 lines
1.7 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import data from '../first-time-state';
|
||
4 years ago
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||
4 years ago
|
import migration25 from './025';
|
||
5 years ago
|
|
||
7 years ago
|
const firstTimeState = {
|
||
|
meta: {},
|
||
5 years ago
|
data,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
|
const storage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
TransactionController: {
|
||
|
transactions: [],
|
||
7 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
4 years ago
|
const transactions = [];
|
||
7 years ago
|
|
||
|
while (transactions.length <= 10) {
|
||
4 years ago
|
transactions.push({
|
||
|
txParams: {
|
||
|
from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
|
||
|
random: 'stuff',
|
||
|
chainId: 2,
|
||
|
},
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
});
|
||
4 years ago
|
transactions.push({
|
||
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
});
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
storage.data.TransactionController.transactions = transactions;
|
||
7 years ago
|
|
||
5 years ago
|
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
|
||
|
it('should lowercase the from for unapproved txs', function (done) {
|
||
4 years ago
|
migration25
|
||
|
.migrate(storage)
|
||
5 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
const migratedTransactions =
|
||
4 years ago
|
migratedData.data.TransactionController.transactions;
|
||
5 years ago
|
migratedTransactions.forEach((tx) => {
|
||
4 years ago
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||
4 years ago
|
assert(!tx.txParams.random);
|
||
5 years ago
|
}
|
||
4 years ago
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||
4 years ago
|
assert(!tx.txParams.chainId);
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should migrate first time state', function (done) {
|
||
4 years ago
|
migration25
|
||
|
.migrate(firstTimeState)
|
||
5 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
assert.equal(migratedData.meta.version, 25);
|
||
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|