From 4efc718074a819c15beceece5e0f08b49c8b60bb Mon Sep 17 00:00:00 2001 From: frankiebee Date: Thu, 5 Apr 2018 11:28:25 -0700 Subject: [PATCH] make migration-24 compat with first-time-state --- app/scripts/migrations/024.js | 2 +- test/unit/migrations/024-test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/scripts/migrations/024.js b/app/scripts/migrations/024.js index 7a0391805..043b47ccc 100644 --- a/app/scripts/migrations/024.js +++ b/app/scripts/migrations/024.js @@ -29,8 +29,8 @@ module.exports = { function transformState (state) { const newState = state + if (!newState.TransactionController) return newState const transactions = newState.TransactionController.transactions - newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => { if ( txMeta.status === 'unapproved' && diff --git a/test/unit/migrations/024-test.js b/test/unit/migrations/024-test.js index dab77d4e4..c3c03d06b 100644 --- a/test/unit/migrations/024-test.js +++ b/test/unit/migrations/024-test.js @@ -1,5 +1,9 @@ const assert = require('assert') const migration24 = require('../../../app/scripts/migrations/024') +const firstTimeState = { + meta: {}, + data: require('../../../app/scripts/first-time-state'), +} const properTime = (new Date()).getTime() const storage = { "meta": {}, @@ -34,4 +38,12 @@ describe('storage is migrated successfully and the txParams.from are lowercase', done() }).catch(done) }) + + it('should migrate first time state', (done) => { + migration24.migrate(firstTimeState) + .then((migratedData) => { + assert.equal(migratedData.meta.version, 24) + done() + }).catch(done) + }) })