2020-01-09 04:34:58 +01:00
|
|
|
import assert from 'assert'
|
|
|
|
import migration24 from '../../../app/scripts/migrations/024'
|
|
|
|
import data from '../../../app/scripts/first-time-state'
|
|
|
|
|
2018-04-05 20:28:25 +02:00
|
|
|
const firstTimeState = {
|
|
|
|
meta: {},
|
2020-01-09 04:34:58 +01:00
|
|
|
data,
|
2018-04-05 20:28:25 +02: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
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const transactions = []
|
|
|
|
|
|
|
|
while (transactions.length <= 10) {
|
2020-11-03 00:41:28 +01:00
|
|
|
transactions.push({
|
|
|
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
|
|
|
status: 'unapproved',
|
|
|
|
})
|
|
|
|
transactions.push({
|
|
|
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
|
|
|
status: 'confirmed',
|
|
|
|
})
|
2018-04-04 23:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
storage.data.TransactionController.transactions = transactions
|
|
|
|
|
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 =
|
|
|
|
migratedData.data.TransactionController.transactions
|
2019-07-31 22:17:11 +02:00
|
|
|
migratedTransactions.forEach((tx) => {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (tx.status === 'unapproved') {
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
tx.txParams.from,
|
|
|
|
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
|
|
|
)
|
2019-11-20 01:03:20 +01:00
|
|
|
} else {
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
tx.txParams.from,
|
|
|
|
'0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
|
|
|
|
)
|
2019-11-20 01:03:20 +01:00
|
|
|
}
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
|
|
|
done()
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.catch(done)
|
2018-04-04 23:22:46 +02:00
|
|
|
})
|
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) => {
|
|
|
|
assert.equal(migratedData.meta.version, 24)
|
|
|
|
done()
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.catch(done)
|
2018-04-05 20:28:25 +02:00
|
|
|
})
|
2018-04-04 23:22:46 +02:00
|
|
|
})
|