diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/lib/first-time.js | 48 | ||||
-rw-r--r-- | test/integration/mocks/badVault.json | 2 | ||||
-rw-r--r-- | test/integration/mocks/badVault2.json | 2 | ||||
-rw-r--r-- | test/integration/mocks/oldVault.json | 2 | ||||
-rw-r--r-- | test/lib/migrations/004.json | 138 | ||||
-rw-r--r-- | test/unit/config-manager-test.js | 34 | ||||
-rw-r--r-- | test/unit/migrations-test.js | 91 |
7 files changed, 247 insertions, 70 deletions
diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 6e75eb6d7..55a16ef38 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -2,7 +2,7 @@ const PASSWORD = 'password123' QUnit.module('first time usage') -QUnit.test('agree to terms', function (assert) { +QUnit.test('render init screen', function (assert) { var done = assert.async() let app @@ -10,22 +10,6 @@ QUnit.test('agree to terms', function (assert) { app = $('iframe').contents().find('#app-content .mock-app-root') // Scroll through terms - var termsHeader = app.find('h3.terms-header')[0] - assert.equal(termsHeader.textContent, 'MetaMask Terms & Conditions', 'Showing TOS') - let termsPage = app.find('.markdown')[0] - assert.ok(termsPage, 'on terms page') - termsPage.scrollTop = termsPage.scrollHeight - - return wait() - }).then(function() { - - // Agree to terms - var button = app.find('button')[0] - button.click() - - return wait() - }).then(function() { - var title = app.find('h1').text() assert.equal(title, 'MetaMask', 'title screen') @@ -34,7 +18,7 @@ QUnit.test('agree to terms', function (assert) { var confBox = app.find('#password-box-confirm')[0] pwBox.value = PASSWORD confBox.value = PASSWORD - + return wait() }).then(function() { @@ -86,6 +70,34 @@ QUnit.test('agree to terms', function (assert) { var detail = app.find('.account-detail-section')[0] assert.ok(detail, 'Account detail section loaded again.') + return wait() + }).then(function (){ + + var qrButton = app.find('.fa.fa-qrcode')[0] + qrButton.click() + + return wait(1000) + }).then(function (){ + + var qrHeader = app.find('.qr-header')[0] + var qrContainer = app.find('#qr-container')[0] + assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.') + assert.ok(qrContainer, 'QR Container found') + + return wait() + }).then(function (){ + + var networkMenu = app.find('.network-indicator')[0] + networkMenu.click() + + return wait() + }).then(function (){ + + var networkMenu = app.find('.network-indicator')[0] + var children = networkMenu.children + children.length[3] + assert.ok(children, 'All network options present') + done() }) }) diff --git a/test/integration/mocks/badVault.json b/test/integration/mocks/badVault.json index a59e4626a..83b4f6298 100644 --- a/test/integration/mocks/badVault.json +++ b/test/integration/mocks/badVault.json @@ -1 +1 @@ -{"meta":{"version":4},"data":{"fiatCurrency":"USD","conversionRate":8.34908448,"conversionDate":1481227505,"isConfirmed":true,"wallet":"{\"encSeed\":{\"encStr\":\"Te2KyAGY3S01bgUJ+7d4y3BOvr/8TKrXrkRZ29cGI6dgyedtN+YgTQxElC2td/pzuoXm7KeSfr+yAoFCvMgqFAJwRcX3arHOsMFQie8kp8mL5I65zwdg/HB2QecB4OJHytrxgApv2zZiKEo0kbu2cs8zYIn5wNlCBIHwgylYmHpUDIJcO1B4zg==\",\"nonce\":\"xnxqk4iy70bjt721F+KPLV4PNfBFNyct\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"vNrSjekRKLmaGFf77Uca9+aAebmDlvrBwtAV8YthpQ4OX/mXtLSycmnLsYdk4schaByfJvrm6/Mf9fxzOSaScJk+XvKw5XqNXedkDHtbWrmNnxFpuT+9tuB8Nupr3D9GZK9PgXhJD99/7Bn6Wk7/ne+PIDmbtdmx/SWmrdo3pg==\",\"nonce\":\"zqWq/gtJ5zfUVRWQQJkP/zoYjer6Rozj\"},\"hdIndex\":1,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"jBLQ9v1l5LOEY1C3kI8z7LpbJKHP1vpVfPAlz90MNSfa8Oe+XlxKQAGYs8Zb4fWm\",\"nonce\":\"fJyrSRo1t0RMNqp2MsneoJnYJWHQnSVY\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\"]}},\"encHdRootPriv\":{\"encStr\":\"mbvwiFBQGbjj4BJLmdeYzfYi8jb7gtFtwiCQOPfvmyz4h2/KMbHNGzumM16qRKpifioQXkhnBulMIQHaYg0Jwv1MoFsqHxHmuIAT+QP5XvJjz0MRl6708pHowmIVG+R8CZNTLqzE7XS8YkZ4ElRpTvLEM8Wngi5Sg287mQMP9w==\",\"nonce\":\"i5Tp2lQe92rXQzNhjZcu9fNNhfux6Wf4\"},\"salt\":\"FQpA8D9R/5qSp9WtQ94FILyfWZHMI6YZw6RmBYqK0N0=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isEthConfirmed":true,"transactions":[],"TOSHash":"a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b","gasMultiplier":1}} +{"meta":{"version":4},"data":{"fiatCurrency":"USD","conversionRate":8.34908448,"conversionDate":1481227505,"wallet":"{\"encSeed\":{\"encStr\":\"Te2KyAGY3S01bgUJ+7d4y3BOvr/8TKrXrkRZ29cGI6dgyedtN+YgTQxElC2td/pzuoXm7KeSfr+yAoFCvMgqFAJwRcX3arHOsMFQie8kp8mL5I65zwdg/HB2QecB4OJHytrxgApv2zZiKEo0kbu2cs8zYIn5wNlCBIHwgylYmHpUDIJcO1B4zg==\",\"nonce\":\"xnxqk4iy70bjt721F+KPLV4PNfBFNyct\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"vNrSjekRKLmaGFf77Uca9+aAebmDlvrBwtAV8YthpQ4OX/mXtLSycmnLsYdk4schaByfJvrm6/Mf9fxzOSaScJk+XvKw5XqNXedkDHtbWrmNnxFpuT+9tuB8Nupr3D9GZK9PgXhJD99/7Bn6Wk7/ne+PIDmbtdmx/SWmrdo3pg==\",\"nonce\":\"zqWq/gtJ5zfUVRWQQJkP/zoYjer6Rozj\"},\"hdIndex\":1,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"jBLQ9v1l5LOEY1C3kI8z7LpbJKHP1vpVfPAlz90MNSfa8Oe+XlxKQAGYs8Zb4fWm\",\"nonce\":\"fJyrSRo1t0RMNqp2MsneoJnYJWHQnSVY\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\"]}},\"encHdRootPriv\":{\"encStr\":\"mbvwiFBQGbjj4BJLmdeYzfYi8jb7gtFtwiCQOPfvmyz4h2/KMbHNGzumM16qRKpifioQXkhnBulMIQHaYg0Jwv1MoFsqHxHmuIAT+QP5XvJjz0MRl6708pHowmIVG+R8CZNTLqzE7XS8YkZ4ElRpTvLEM8Wngi5Sg287mQMP9w==\",\"nonce\":\"i5Tp2lQe92rXQzNhjZcu9fNNhfux6Wf4\"},\"salt\":\"FQpA8D9R/5qSp9WtQ94FILyfWZHMI6YZw6RmBYqK0N0=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isEthConfirmed":true,"transactions":[],"gasMultiplier":1}} diff --git a/test/integration/mocks/badVault2.json b/test/integration/mocks/badVault2.json index 4b7aec386..e849ca62a 100644 --- a/test/integration/mocks/badVault2.json +++ b/test/integration/mocks/badVault2.json @@ -1 +1 @@ -{"meta":{"version":4},"data":{"fiatCurrency":"USD","isConfirmed":true,"TOSHash":"a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b","noticesList":[{"read":true,"date":"Fri Dec 16 2016","title":"Ending Morden Support","body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n","id":0}],"conversionRate":7.07341909,"conversionDate":1482539284,"wallet":"{\"encSeed\":{\"encStr\":\"LZsdN8lJzYkUe1UpmAalnERdgkBFt25gWDdK8kfQUwMAk/27XR+dc+8n5swgoF5qgwhc9LBgliEGNDs1Q/lnuld3aQLabkOeAW4BHS1vS7FxqKrzDS3iyzSuQO6wDQmGno/buuknVgDsKiyjW22hpt7vtVVWA+ZL1P3x6M0+AxGJjeGVrG+E8Q==\",\"nonce\":\"T6O9BmwmTj214XUK3KF0s3iCKo3OlrUD\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"GNNfZevCMlgMVh9y21y1UwrC9qcmH6XYq7v+9UoqbHnzPQJFlxidN5+x/Sldo72a6+5zJpQkkdZ+Q0lePrzvXfuSd3D/RO7WKFIKo9nAQI5+JWwz4INuCmVcmqCv2J4BTLGjrG8fp5pDJ62Bn0XHqkJo3gx3fpvs3cS66+ZKwg==\",\"nonce\":\"HRTlGj44khQs2veYHEF/GqTI1t0yYvyd\"},\"hdIndex\":3,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"ZAeZL9VcRUtiiO4VXOQKBFg787PR5R3iymjUeU5vpDRIqOXbjWN6N4ZNR8YpSXl+\",\"nonce\":\"xLsADagS8uqDYae6cImyhxF7o1kBDbPe\"},\"87658c15aefe7448008a28513a11b6b130ef4cd0\":{\"key\":\"ku0mm5s1agRJNAMYIJO0qeoDe+FqcbqdQI6azXF3GL1OLo6uMlt6I4qS+eeravFi\",\"nonce\":\"xdGfSUPKtkW8ge0SWIbbpahs/NyEMzn5\"},\"aa25854c0379e53c957ac9382e720c577fa31fd5\":{\"key\":\"NjpYC9FbiC95CTx/1kwgOHk5LSN9vl4RULEBbvwfVOjqSH8WixNoP3R6I/QyNIs2\",\"nonce\":\"M/HWpXXA9QvuZxEykkGQPJKKdz33ovQr\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\",\"87658c15aefe7448008a28513a11b6b130ef4cd0\",\"aa25854c0379e53c957ac9382e720c577fa31fd5\"]}},\"encHdRootPriv\":{\"encStr\":\"f+3prUOzl+95aNAV+ad6lZdsYZz120ZsL67ucjj3tiMXf/CC4X8XB9N2QguhoMy6fW+fATUsTdJe8+CbAAyb79V9HY0Pitzq9Yw/g1g0/Ii2JzsdGBriuMsPdwZSVqz+rvQFw/6Qms1xjW6cqa8S7kM2WA5l8RB1Ck6r5zaqbA==\",\"nonce\":\"oGahxNFekVxH9sg6PUCCHIByvo4WFSqm\"},\"salt\":\"N7xYoEA53yhSweOsEphku1UKkIEuZtX2MwLBhVM6RR8=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isDisclaimerConfirmed":true,"walletNicknames":{"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9":"Account 1","0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4":"Account 2","0x1acfb961c5a8268eac8e09d6241a26cbeff42241":"Account 3"},"lostAccounts":["0xe15d894becb0354c501ae69429b05143679f39e0","0x87658c15aefe7448008a28513a11b6b130ef4cd0","0xaa25854c0379e53c957ac9382e720c577fa31fd5"]}}
\ No newline at end of file +{"meta":{"version":4},"data":{"fiatCurrency":"USD","noticesList":[{"read":true,"date":"Fri Dec 16 2016","title":"Ending Morden Support","body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n","id":0}],"conversionRate":7.07341909,"conversionDate":1482539284,"wallet":"{\"encSeed\":{\"encStr\":\"LZsdN8lJzYkUe1UpmAalnERdgkBFt25gWDdK8kfQUwMAk/27XR+dc+8n5swgoF5qgwhc9LBgliEGNDs1Q/lnuld3aQLabkOeAW4BHS1vS7FxqKrzDS3iyzSuQO6wDQmGno/buuknVgDsKiyjW22hpt7vtVVWA+ZL1P3x6M0+AxGJjeGVrG+E8Q==\",\"nonce\":\"T6O9BmwmTj214XUK3KF0s3iCKo3OlrUD\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"GNNfZevCMlgMVh9y21y1UwrC9qcmH6XYq7v+9UoqbHnzPQJFlxidN5+x/Sldo72a6+5zJpQkkdZ+Q0lePrzvXfuSd3D/RO7WKFIKo9nAQI5+JWwz4INuCmVcmqCv2J4BTLGjrG8fp5pDJ62Bn0XHqkJo3gx3fpvs3cS66+ZKwg==\",\"nonce\":\"HRTlGj44khQs2veYHEF/GqTI1t0yYvyd\"},\"hdIndex\":3,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"ZAeZL9VcRUtiiO4VXOQKBFg787PR5R3iymjUeU5vpDRIqOXbjWN6N4ZNR8YpSXl+\",\"nonce\":\"xLsADagS8uqDYae6cImyhxF7o1kBDbPe\"},\"87658c15aefe7448008a28513a11b6b130ef4cd0\":{\"key\":\"ku0mm5s1agRJNAMYIJO0qeoDe+FqcbqdQI6azXF3GL1OLo6uMlt6I4qS+eeravFi\",\"nonce\":\"xdGfSUPKtkW8ge0SWIbbpahs/NyEMzn5\"},\"aa25854c0379e53c957ac9382e720c577fa31fd5\":{\"key\":\"NjpYC9FbiC95CTx/1kwgOHk5LSN9vl4RULEBbvwfVOjqSH8WixNoP3R6I/QyNIs2\",\"nonce\":\"M/HWpXXA9QvuZxEykkGQPJKKdz33ovQr\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\",\"87658c15aefe7448008a28513a11b6b130ef4cd0\",\"aa25854c0379e53c957ac9382e720c577fa31fd5\"]}},\"encHdRootPriv\":{\"encStr\":\"f+3prUOzl+95aNAV+ad6lZdsYZz120ZsL67ucjj3tiMXf/CC4X8XB9N2QguhoMy6fW+fATUsTdJe8+CbAAyb79V9HY0Pitzq9Yw/g1g0/Ii2JzsdGBriuMsPdwZSVqz+rvQFw/6Qms1xjW6cqa8S7kM2WA5l8RB1Ck6r5zaqbA==\",\"nonce\":\"oGahxNFekVxH9sg6PUCCHIByvo4WFSqm\"},\"salt\":\"N7xYoEA53yhSweOsEphku1UKkIEuZtX2MwLBhVM6RR8=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"walletNicknames":{"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9":"Account 1","0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4":"Account 2","0x1acfb961c5a8268eac8e09d6241a26cbeff42241":"Account 3"},"lostAccounts":["0xe15d894becb0354c501ae69429b05143679f39e0","0x87658c15aefe7448008a28513a11b6b130ef4cd0","0xaa25854c0379e53c957ac9382e720c577fa31fd5"]}} diff --git a/test/integration/mocks/oldVault.json b/test/integration/mocks/oldVault.json index b908ed7ca..dbcd91575 100644 --- a/test/integration/mocks/oldVault.json +++ b/test/integration/mocks/oldVault.json @@ -4,8 +4,6 @@ }, "data": { "fiatCurrency": "USD", - "isConfirmed": true, - "TOSHash": "a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b", "conversionRate": 9.47316629, "conversionDate": 1479510994, "wallet": "{\"encSeed\":{\"encStr\":\"a5tjKtDGlHkua+6Ta5s3wMFWPmsBqaPdMKGmqeI2z1kMbNs3V03HBaCptU7NtMra1DjHKbSNsUToxFUrmrvWBmUejamN16+l1CviwqASsv7kKzpot00/dfyyJgtZwwFP5Je+TAB1V231nRbPidOfeE1cDec5V8KTF8epl6qzsbA25pjeW76Dfw==\",\"nonce\":\"RzID6bAhWfGTSR74xdIh3RaT1+1sLk6F\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"6nlYAopRbmGcqerRZO08XwgeYaCJg9XRhh4oiYiVVdQtyNPdxvOI9TcE/mqvBiatMwBwA+TmsqTV6eZZe/VDZKYIGajKulQbScd0xQ71JhYfqqmzSG6EH2Pnzwa+aSAsfARgN1JJSaff2+p6wV6Zg5BUDtl72OGEIEfXhcUGwg==\",\"nonce\":\"Ee1KiDqtx7NvYToQUFvjEhKNinNQcXlK\"},\"hdIndex\":1,\"encPrivKeys\":{\"4dd5d356c5a016a220bcd69e82e5af680a430d00\":{\"key\":\"htGRGAH10lGF4M+fvioznmYVIUSWAzwp/yWSIo85psgZZwmCdJY72oyGanYsrFO8\",\"nonce\":\"PkP8XeZ+ok215rzEorvJu9nYTWzkOVr0\"}},\"addresses\":[\"4dd5d356c5a016a220bcd69e82e5af680a430d00\"]}},\"encHdRootPriv\":{\"encStr\":\"TAZAo71a+4IlAaoA66f0w4ts2f+V7ArTSUHRIrMltfAPXz7GfJBmKXNtHPORUYAjRiKqWK6FZnhKLf7Vcng2LG7VnDQwC4xPxzSRZzSEilnoY3V+zRY0HD7Wb/pndb4FliA/buZQmjohO4vezeX0hl70rJlPJEZTyYoWgxbxFA==\",\"nonce\":\"FlJOaLyBEHMaH5fEnYjdHc6nn18+WkRj\"},\"salt\":\"CmuCcWpbqpKUUv+1aE2ZwvQl7EIQ731uFibSq++vwtY=\",\"version\":2}", diff --git a/test/lib/migrations/004.json b/test/lib/migrations/004.json new file mode 100644 index 000000000..0e2075c46 --- /dev/null +++ b/test/lib/migrations/004.json @@ -0,0 +1,138 @@ +{ + "meta":{ + "version":4 + }, + "data":{ + "seedWords":null, + "fiatCurrency":"USD", + "isDisclaimerConfirmed":true, + "TOSHash":"a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b", + "shapeShiftTxList":[ + { + "depositAddress": "1L8BJCR6KHkCiVceDqibt7zJscqPpH7pFw", + "depositType": "BTC", + "key": "shapeshift", + "time": 1471564825772, + "response": { + "status": "complete", + "outgoingCoin": "100.00", + "incomingCoin": "1.000", + "transaction": "0x3701e0ac344a12a1fc5417cf251109a7c41f3edab922310202630d9c012414c8" + } + }, + { + "depositAddress": "1L8BJCR6KHkCiVceDqibt7zJscqPpH7pFw", + "depositType": "BTC", + "key": "shapeshift", + "time": 1471566579224, + "response": { + "status": "no_deposits", + "depositAddress": "1L8BJCR6KHkCiVceDqibt7zJscqPpH7pFw" + } + }, + { + "depositAddress": "1L8BJCR6KHkCiVceDqibt7zJscqPpH7pFw", + "depositType": "BTC", + "key": "shapeshift", + "time": 1471566565378, + "response": { + "status": "received", + "depositAddress": "1L8BJCR6KHkCiVceDqibt7zJscqPpH7pFw" + } + } + ], + "noticesList":[ + { + "read":true, + "date":"Fri Dec 16 2016", + "title":"Ending Morden Support", + "body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n", + "id":0 + } + ], + "conversionRate":12.66441492, + "conversionDate":1487184182, + "vault":"{\"data\":\"Z5UFCeI/Tg9F9No0dC7eIhe4evCG91m6qeXhGpSeX48HHCQ/BepyNONKrh05YjB9hXCAd3Jy93judD+pcXNy7WS9zLujjmMI6sI90ToSrzThnMrOE6ixcH7HGS+TCcqvwBhZEsAQqUcQeHhT9CcdCQAxkKwBk8CK8W290MVeZoQVGK88hB2R8kL3mo/uayS5AnHPwWOS0rocgSfd/ioiucClpw==\",\"iv\":\"AYufeEPwp9f2Rdrfq7yS8g==\",\"salt\":\"g7BQIEx8tosH3IxWhPnrgZFu1XRkQn1Pp7l1ehTQQCo=\"}", + "config":{ + "provider":{ + "type":"testnet" + }, + "selectedAccount":"0x0beb674745816b125fbc07285d39fd373e64895c" + }, + "walletNicknames":{ + "0x0beb674745816b125fbc07285d39fd373e64895c":"Account 1", + "0x433eb37d2e4895815b90f555425dfa123ddaed40":"Account 2" + }, + "transactions":[ + { + "id":3922064325443430, + "time":1487184358262, + "status":"confirmed", + "gasMultiplier":1, + "metamaskNetworkId":"3", + "txParams":{ + "from":"0x0beb674745816b125fbc07285d39fd373e64895c", + "to":"0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761", + "value":"0xde0b6b3a7640000", + "metamaskId":3922064325443430, + "metamaskNetworkId":"3", + "gas":"0x5209", + "gasPrice":"0x04a817c800", + "nonce":"0x0", + "gasLimit":"0x5209" + }, + "gasLimitSpecified":false, + "estimatedGas":"0x5209", + "txFee":"17e0186e60800", + "txValue":"de0b6b3a7640000", + "maxCost":"de234b52e4a0800", + "hash":"0x0b36c5bb31528044e6a71e45a64e9872f5f365a14ac42ee1bea49e7766216c12" + }, + { + "id":3922064325443431, + "time":1487184373172, + "status":"confirmed", + "gasMultiplier":1, + "metamaskNetworkId":"3", + "txParams":{ + "from":"0x0beb674745816b125fbc07285d39fd373e64895c", + "to":"0x433eb37d2e4895815b90f555425dfa123ddaed40", + "value":"0xde0b6b3a7640000", + "metamaskId":3922064325443431, + "metamaskNetworkId":"3", + "gas":"0x5209", + "nonce":"0x01", + "gasPrice":"0x04a817c800", + "gasLimit":"0x5209" + }, + "gasLimitSpecified":false, + "estimatedGas":"0x5209", + "txFee":"17e0186e60800", + "txValue":"de0b6b3a7640000", + "maxCost":"de234b52e4a0800", + "hash":"0x305548a8b8bb72de0ca8cf77df45e4fe2b29383e58c4da6b7eac7e9bd59e85e9" + }, + { + "id":3922064325443432, + "time":1487184391226, + "status":"unapproved", + "gasMultiplier":1, + "metamaskNetworkId":"3", + "txParams":{ + "from":"0x0beb674745816b125fbc07285d39fd373e64895c", + "to":"0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761", + "value":"0xde0b6b3a7640000", + "metamaskId":3922064325443432, + "metamaskNetworkId":"3", + "gas":"0x5209" + }, + "gasLimitSpecified":false, + "estimatedGas":"0x5209", + "txFee":"17e0186e60800", + "txValue":"de0b6b3a7640000", + "maxCost":"de234b52e4a0800" + } + ], + "gasMultiplier":1 + } +} diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js index c6f60192f..05324e741 100644 --- a/test/unit/config-manager-test.js +++ b/test/unit/config-manager-test.js @@ -14,37 +14,6 @@ describe('config-manager', function() { configManager = configManagerGen() }) - describe('confirmation', function() { - - describe('#getConfirmedDisclaimer', function() { - it('should return undefined if no previous key exists', function() { - var result = configManager.getConfirmedDisclaimer() - assert.ok(!result) - }) - }) - - describe('#setConfirmedDisclaimer', function() { - it('should make getConfirmedDisclaimer return true once set', function() { - assert.equal(configManager.getConfirmedDisclaimer(), undefined) - configManager.setConfirmedDisclaimer(true) - var result = configManager.getConfirmedDisclaimer() - assert.equal(result, true) - }) - - it('should be able to set undefined', function() { - configManager.setConfirmedDisclaimer(undefined) - var result = configManager.getConfirmedDisclaimer() - assert.equal(result, undefined) - }) - - it('should persist to local storage', function() { - configManager.setConfirmedDisclaimer(true) - var data = configManager.getData() - assert.equal(data.isDisclaimerConfirmed, true) - }) - }) - }) - describe('#setConfig', function() { it('should set the config key', function () { @@ -68,7 +37,6 @@ describe('config-manager', function() { rpcTarget: 'foobar' }, } - configManager.setConfirmedDisclaimer(true) configManager.setConfig(testConfig) var testWallet = { @@ -79,7 +47,6 @@ describe('config-manager', function() { var result = configManager.getData() assert.equal(result.wallet.name, testWallet.name, 'wallet name is set') assert.equal(result.config.provider.rpcTarget, testConfig.provider.rpcTarget) - assert.equal(configManager.getConfirmedDisclaimer(), true) testConfig.provider.type = 'something else!' configManager.setConfig(testConfig) @@ -88,7 +55,6 @@ describe('config-manager', function() { assert.equal(result.wallet.name, testWallet.name, 'wallet name is set') assert.equal(result.config.provider.rpcTarget, testConfig.provider.rpcTarget) assert.equal(result.config.provider.type, testConfig.provider.type) - assert.equal(configManager.getConfirmedDisclaimer(), true) }) }) diff --git a/test/unit/migrations-test.js b/test/unit/migrations-test.js index 715a5feb0..d2a83be77 100644 --- a/test/unit/migrations-test.js +++ b/test/unit/migrations-test.js @@ -2,33 +2,96 @@ const assert = require('assert') const path = require('path') const wallet1 = require(path.join('..', 'lib', 'migrations', '001.json')) +const vault4 = require(path.join('..', 'lib', 'migrations', '004.json')) +let vault5, vault6, vault7, vault8, vault9, vault10, vault11 const migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002')) const migration3 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '003')) const migration4 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '004')) +const migration5 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '005')) +const migration6 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '006')) +const migration7 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '007')) +const migration8 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '008')) +const migration9 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '009')) +const migration10 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '010')) +const migration11 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '011')) const oldTestRpc = 'https://rawtestrpc.metamask.io/' const newTestRpc = 'https://testrpc.metamask.io/' -describe('wallet1 is migrated successfully', function() { - it('should convert providers', function() { +describe('wallet1 is migrated successfully', () => { + it('should convert providers', () => { wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null } return migration2.migrate(wallet1) - .then((firstResult) => { - assert.equal(firstResult.data.config.provider.type, 'rpc', 'provider should be rpc') - assert.equal(firstResult.data.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc') - firstResult.data.config.provider.rpcTarget = oldTestRpc - return migration3.migrate(firstResult) - }).then((secondResult) => { - assert.equal(secondResult.data.config.provider.rpcTarget, newTestRpc) - return migration4.migrate(secondResult) + .then((secondResult) => { + const secondData = secondResult.data + assert.equal(secondData.config.provider.type, 'rpc', 'provider should be rpc') + assert.equal(secondData.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'main provider should be our rpc') + secondResult.data.config.provider.rpcTarget = oldTestRpc + return migration3.migrate(secondResult) }).then((thirdResult) => { - assert.equal(thirdResult.data.config.provider.rpcTarget, null) - assert.equal(thirdResult.data.config.provider.type, 'testnet') + assert.equal(thirdResult.data.config.provider.rpcTarget, newTestRpc, 'config.provider.rpcTarget should be set to the proper testrpc url.') + return migration4.migrate(thirdResult) + }).then((fourthResult) => { + const fourthData = fourthResult.data + assert.equal(fourthData.config.provider.rpcTarget, null, 'old rpcTarget should not exist.') + assert.equal(fourthData.config.provider.type, 'testnet', 'config.provider should be set to testnet.') + + return migration5.migrate(vault4) + }).then((fifthResult) => { + const fifthData = fifthResult.data + assert.equal(fifthData.vault, null, 'old vault should not exist') + assert.equal(fifthData.walletNicknames, null, 'old walletNicknames should not exist') + assert.equal(fifthData.config.selectedAccount, null, 'old config.selectedAccount should not exist') + assert.equal(fifthData.KeyringController.vault, vault4.data.vault, 'KeyringController.vault should exist') + assert.equal(fifthData.KeyringController.selectedAccount, vault4.data.config.selectedAccount, 'KeyringController.selectedAccount should have moved') + assert.equal(fifthData.KeyringController.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], vault4.data.walletNicknames['0x0beb674745816b125fbc07285d39fd373e64895c'], 'KeyringController.walletNicknames should have moved') + + vault5 = fifthResult + return migration6.migrate(fifthResult) + }).then((sixthResult) => { + assert.equal(sixthResult.data.KeyringController.selectedAccount, null, 'old selectedAccount should not exist') + assert.equal(sixthResult.data.PreferencesController.selectedAddress, vault5.data.KeyringController.selectedAccount, 'selectedAccount should have moved') + + vault6 = sixthResult + return migration7.migrate(sixthResult) + }).then((seventhResult) => { + assert.equal(seventhResult.data.transactions, null, 'old transactions should not exist') + assert.equal(seventhResult.data.gasMultiplier, null, 'old gasMultiplier should not exist') + assert.equal(seventhResult.data.TransactionManager.transactions[0].id, vault6.data.transactions[0].id, 'transactions should have moved') + assert.equal(seventhResult.data.TransactionManager.gasMultiplier, vault6.data.gasMultiplier, 'gasMultiplier should have moved') + + vault7 = seventhResult + return migration8.migrate(seventhResult) + }).then((eighthResult) => { + assert.equal(eighthResult.data.noticesList, null, 'old noticesList should not exist') + assert.equal(eighthResult.data.NoticeController.noticesList[0].title, vault7.data.noticesList[0].title, 'noticesList should have moved') + + vault8 = eighthResult + return migration9.migrate(eighthResult) + }).then((ninthResult) => { + assert.equal(ninthResult.data.currentFiat, null, 'old currentFiat should not exist') + assert.equal(ninthResult.data.fiatCurrency, null, 'old fiatCurrency should not exist') + assert.equal(ninthResult.data.conversionRate, null, 'old conversionRate should not exist') + assert.equal(ninthResult.data.conversionDate, null, 'old conversionDate should not exist') + + assert.equal(ninthResult.data.CurrencyController.currentCurrency, vault8.data.fiatCurrency, 'currentFiat should have moved') + assert.equal(ninthResult.data.CurrencyController.conversionRate, vault8.data.conversionRate, 'conversionRate should have moved') + assert.equal(ninthResult.data.CurrencyController.conversionDate, vault8.data.conversionDate, 'conversionDate should have moved') + + vault9 = ninthResult + return migration10.migrate(ninthResult) + }).then((tenthResult) => { + assert.equal(tenthResult.data.shapeShiftTxList, null, 'old shapeShiftTxList should not exist') + assert.equal(tenthResult.data.ShapeShiftController.shapeShiftTxList[0].transaction, vault9.data.shapeShiftTxList[0].transaction) + + return migration11.migrate(tenthResult) + }).then((eleventhResult) => { + assert.equal(eleventhResult.data.isDisclaimerConfirmed, null, 'isDisclaimerConfirmed should not exist') + assert.equal(eleventhResult.data.TOSHash, null, 'TOSHash should not exist') }) - + }) }) - |