aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/migrations
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-04-06 09:05:03 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-04-06 09:05:03 +0800
commit7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12 (patch)
tree0dd0b39f45d67b88b9eda83337fdf5c2a6f45864 /test/unit/migrations
parent1ba74c1566fe67f610a730c362b3989e63787d4c (diff)
downloadtangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar.gz
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar.bz2
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar.lz
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar.xz
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.tar.zst
tangerine-wallet-browser-7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12.zip
create migration 25
Diffstat (limited to 'test/unit/migrations')
-rw-r--r--test/unit/migrations/025-test.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/unit/migrations/025-test.js b/test/unit/migrations/025-test.js
new file mode 100644
index 000000000..76c25dbb6
--- /dev/null
+++ b/test/unit/migrations/025-test.js
@@ -0,0 +1,49 @@
+const assert = require('assert')
+const migration25 = require('../../../app/scripts/migrations/025')
+const firstTimeState = {
+ meta: {},
+ data: require('../../../app/scripts/first-time-state'),
+}
+
+const storage = {
+ "meta": {},
+ "data": {
+ "TransactionController": {
+ "transactions": [
+ ]
+ },
+ },
+}
+
+const transactions = []
+
+
+while (transactions.length <= 10) {
+ transactions.push({ txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675', random: 'stuff', chainId: 2 }, 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) => {
+ migration25.migrate(storage)
+ .then((migratedData) => {
+ const migratedTransactions = migratedData.data.TransactionController.transactions
+ migratedTransactions.forEach((tx) => {
+ if (tx.status === 'unapproved') assert(!tx.txParams.random)
+ if (tx.status === 'unapproved') assert(!tx.txParams.chainId)
+ })
+ done()
+ }).catch(done)
+ })
+
+ it('should migrate first time state', (done) => {
+ migration25.migrate(firstTimeState)
+ .then((migratedData) => {
+ assert.equal(migratedData.meta.version, 25)
+ done()
+ }).catch(done)
+ })
+})