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 = {
|
2018-07-03 00:49:33 +02:00
|
|
|
'meta': {},
|
|
|
|
'data': {
|
|
|
|
'TransactionController': {
|
|
|
|
'transactions': [
|
|
|
|
],
|
2018-04-04 23:22:46 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const transactions = []
|
|
|
|
|
|
|
|
|
|
|
|
while (transactions.length <= 10) {
|
|
|
|
transactions.push({ txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' }, status: 'unapproved' })
|
|
|
|
transactions.push({ txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' }, status: 'confirmed' })
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
storage.data.TransactionController.transactions = transactions
|
|
|
|
|
|
|
|
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
|
|
|
it('should lowercase the from for unapproved txs', (done) => {
|
|
|
|
migration24.migrate(storage)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((migratedData) => {
|
|
|
|
const migratedTransactions = migratedData.data.TransactionController.transactions
|
|
|
|
migratedTransactions.forEach((tx) => {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (tx.status === 'unapproved') {
|
|
|
|
assert.equal(tx.txParams.from, '0x8acce2391c0d510a6c5e5d8f819a678f79b7e675')
|
|
|
|
} else {
|
|
|
|
assert.equal(tx.txParams.from, '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675')
|
|
|
|
}
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
|
|
|
done()
|
|
|
|
}).catch(done)
|
2018-04-04 23:22:46 +02:00
|
|
|
})
|
2018-04-05 20:28:25 +02:00
|
|
|
|
|
|
|
it('should migrate first time state', (done) => {
|
|
|
|
migration24.migrate(firstTimeState)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((migratedData) => {
|
|
|
|
assert.equal(migratedData.meta.version, 24)
|
|
|
|
done()
|
|
|
|
}).catch(done)
|
2018-04-05 20:28:25 +02:00
|
|
|
})
|
2018-04-04 23:22:46 +02:00
|
|
|
})
|