From a50f3fb50ce6ed2c7a2ea2755ea27249016787de Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 27 Jul 2016 22:31:22 -0300 Subject: [PATCH 1/8] NW v0.16. Migrate localstorage data to chrome.storage --- package.json | 5 ++-- src/js/controllers/index.js | 3 +++ src/js/services/localStorage.js | 41 ++++++++++++++++++++++++++++--- src/js/services/storageService.js | 20 ++++++++++++++- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 9c1253e6f..affe80fff 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,9 @@ "window": { "title": "Copay - A multisignature bitcoin wallet", "icon": "./public/img/icons/icon-256.png", - "toolbar": false, "show": true, "visible": true, - "resizable": false, + "resizable": true, "frame": true, "width": 800, "height": 600, @@ -30,7 +29,7 @@ "java": false, "plugin": false }, - "dom_storage_quota": 100, + "dom_storage_quota": 200, "id": "jid1-x7bV5evAaI1P9Q", "homepage": "https://github.com/bitpay/copay", "license": "MIT", diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index be1713459..9b5c213af 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -20,6 +20,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r ret.prevState = 'walletHome'; ret.physicalScreenWidth = ((window.innerWidth > 0) ? window.innerWidth : screen.width); + // Only for testing + //storageService.checkQuota(); + ret.menu = [{ 'title': gettext('Receive'), 'icon': { diff --git a/src/js/services/localStorage.js b/src/js/services/localStorage.js index 17ab3a27d..2b629ae2e 100644 --- a/src/js/services/localStorage.js +++ b/src/js/services/localStorage.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.services') - .factory('localStorageService', function(platformInfo, $timeout) { + .factory('localStorageService', function(platformInfo, $timeout, $log) { var isNW = platformInfo.isNW; var isChromeApp = platformInfo.isChromeApp; var root = {}; @@ -11,11 +11,12 @@ angular.module('copayApp.services') ls = chrome.storage.local; } + if (!ls) throw new Error('localstorage not available'); root.get = function(k, cb) { - if (isChromeApp && !isNW) { + if (isChromeApp || isNW) { chrome.storage.local.get(k, function(data) { //TODO check for errors @@ -41,7 +42,7 @@ angular.module('copayApp.services') }; root.set = function(k, v, cb) { - if (isChromeApp && !isNW) { + if (isChromeApp || isNW) { var obj = {}; obj[k] = v; @@ -54,7 +55,7 @@ angular.module('copayApp.services') }; root.remove = function(k, cb) { - if (isChromeApp && !isNW) { + if (isChromeApp || isNW) { chrome.storage.local.remove(k, cb); } else { ls.removeItem(k); @@ -63,5 +64,37 @@ angular.module('copayApp.services') }; + + if (isNW) { + $log.info('Overwritting localstorage with chrome storage for NW.JS'); + + var ts = ls.getItem('migrationToChromeStorage'); + var p = ls.getItem('profile'); + + // Need migration? + if (!ts && p) { + $log.info('### MIGRATING DATA! TO CHROME STORAGE'); + + var j = 0; + for (var i = 0; i < localStorage.length; i++) { + var k = ls.key(i); + var v = ls.getItem(k); + + $log.debug(' Key: ' + k); + root.set(k, v, function() { + j++; + if (j == localStorage.length) { + $log.info('### MIGRATION DONE'); + ls.setItem('migrationToChromeStorage', Date.now()) + ls = chrome.storage.local; + } + }) + } + } else if (p) { + $log.info('# Data already migrated to Chrome storage on ' + ts); + } + } + + return root; }); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 1de5ec21e..33eaa819c 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -264,8 +264,26 @@ angular.module('copayApp.services') storage.remove('addressbook-' + network, cb); }; + + root.checkQuota = function() { + var block = ''; + // 50MB + for (var i = 0; i < 1024*1024; ++ i){ + block += '12345678901234567890123456789012345678901234567890'; + } + storage.set('test', block, function(err) { + $log.error('CheckQuota Return:'+ err); + }); + }; + root.setTxHistory = function(txs, walletId, cb) { - storage.set('txsHistory-' + walletId, txs, cb); + try { + storage.set('txsHistory-' + walletId, txs, cb); + } catch (e) { + $log.error('Error saving tx History. Size:' + txs.length); + $log.error(e); + return cb(e); + } } root.getTxHistory = function(walletId, cb) { From 26badd649b049161f0ed1f1aded88eadda6434b9 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 09:07:29 -0300 Subject: [PATCH 2/8] update grunt --- Gruntfile.js | 4 ++-- package.json | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 811946557..1a9ba4ae3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -235,12 +235,12 @@ module.exports = function(grunt) { singleRun: true } }, - nodewebkit: { + nwjs: { options: { appName: 'Copay', platforms: ['win64', 'osx64', 'linux64'], buildDir: './webkitbuilds', - version: '0.12.2', + version: '0.16.0', macIcns: './public/img/icons/icon.icns', exeIco: './public/img/icons/icon.ico' }, diff --git a/package.json b/package.json index affe80fff..e129922ec 100644 --- a/package.json +++ b/package.json @@ -45,16 +45,7 @@ "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", - "grunt": "^0.4.5", - "grunt-angular-gettext": "^0.2.15", - "grunt-browserify": "^4.0.1", - "grunt-cli": "^0.1.13", - "grunt-contrib-compress": "^0.13.0", - "grunt-contrib-concat": "^0.5.1", - "grunt-contrib-copy": "^0.8.1", - "grunt-contrib-uglify": "^0.9.2", - "grunt-contrib-watch": "^0.6.1", - "grunt-exec": "^0.4.6", + "grunt": ">=0.4.0", "shelljs": "^0.3.0" }, "scripts": { @@ -74,9 +65,16 @@ "chai": "^3.5.0", "cordova": "5.4.1", "cordova-android": "5.1.1", - "grunt-karma": "^1.0.0", + "grunt": "^1.0.1", + "grunt-angular-gettext": "^2.2.3", + "grunt-browserify": "^5.0.0", + "grunt-contrib-compress": "^1.3.0", + "grunt-contrib-concat": "^1.0.1", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^2.0.0", + "grunt-exec": "^1.0.0", + "grunt-karma": "^2.0.0", "grunt-karma-coveralls": "^2.5.4", - "grunt-node-webkit-builder": "^1.0.2", "grunt-sass": "^1.2.0", "grunt-string-replace": "^1.2.1", "karma": "^0.13.22", From e93cdbc6f2d7d3f211fcd098ee8b7574a48eca7a Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 09:36:30 -0300 Subject: [PATCH 3/8] update nw builder --- Gruntfile.js | 4 ++-- package.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1a9ba4ae3..188cb81b8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -271,7 +271,7 @@ module.exports = function(grunt) { grunt.registerTask('translate', ['nggettext_extract']); grunt.registerTask('test', ['karma:unit']); grunt.registerTask('test-coveralls', ['browserify', 'karma:prod', 'exec:coveralls']); - grunt.registerTask('desktop', ['prod', 'nodewebkit', 'copy:linux', 'compress:linux']); - grunt.registerTask('osx', ['prod', 'nodewebkit', 'exec:osx']); + grunt.registerTask('desktop', ['prod', 'nwjs', 'copy:linux', 'compress:linux']); + grunt.registerTask('osx', ['prod', 'nwjs', 'exec:osx']); grunt.registerTask('release', ['string-replace:dist']); }; diff --git a/package.json b/package.json index e129922ec..37d59ae42 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "grunt-exec": "^1.0.0", "grunt-karma": "^2.0.0", "grunt-karma-coveralls": "^2.5.4", + "grunt-nw-builder": "^2.0.3", "grunt-sass": "^1.2.0", "grunt-string-replace": "^1.2.1", "karma": "^0.13.22", From eeb7d72c73604ca7f8a1a49fcb42b980262eb0a2 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 11:04:37 -0300 Subject: [PATCH 4/8] update bwc --- package.json | 2 +- test/controllers/disclaimer.test.js | 103 +++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 37d59ae42..ba88d721e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "2.9.0", + "bitcore-wallet-client": "2.10.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", diff --git a/test/controllers/disclaimer.test.js b/test/controllers/disclaimer.test.js index c508d35a8..4390806dd 100644 --- a/test/controllers/disclaimer.test.js +++ b/test/controllers/disclaimer.test.js @@ -48,8 +48,105 @@ describe('disclaimerController', function() { }, "scanStatus": null } - } + }, + //======================================================== + // post wallets + '3295ba1bcd509b7d42928c071999281f7692caa64df43177bec8a6a8c3fa8927': { + "walletId": "24c40723-c360-498d-a803-a6e1e4ef990d" + }, + // post /v2/wallets/24c40723-c360-498d-a803-a6e1e4ef990d/copayers + '5f109ab9572a69feb0654268b8802afa364d6e8217aeaf851416f0394502e90c': { + "copayerId": "6348201ef06ad5b922065fd4e510152c3da3af1196c0cb8f6e34f6e0494fa4a1", + "wallet": { + "version": "1.0.0", + "createdOn": 1469713357, + "id": "24c40723-c360-498d-a803-a6e1e4ef990d", + "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"DK2ZgZ/k/rr5UfXn4Ht1KAAaRp7Wa5E=\"}", + "m": 1, + "n": 1, + "singleAddress": false, + "status": "complete", + "publicKeyRing": [{ + "xPubKey": "xpub6D1Um62Uho1NDw6jYzgqCzase3L9TNLmCn42YuBzP8Vn4q94LwpNbcv3zpJJAS6BVf8YyKfKKqTt9BG9PBzcCbPouGkkci9qMNXTtZRmtAy", + "requestPubKey": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1" + }], + "copayers": [{ + "version": 2, + "createdOn": 1469713357, + "xPubKey": "xpub6D1Um62Uho1NDw6jYzgqCzase3L9TNLmCn42YuBzP8Vn4q94LwpNbcv3zpJJAS6BVf8YyKfKKqTt9BG9PBzcCbPouGkkci9qMNXTtZRmtAy", + "id": "6348201ef06ad5b922065fd4e510152c3da3af1196c0cb8f6e34f6e0494fa4a1", + "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"Ma1tUjOpLrDtSA==\"}", + "requestPubKey": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1", + "signature": "3044022023b43a8dabfa3a2d615135913021bcd4cfe06739e76cdcec91dedcd93f1c034502200e62c491417874b3ef5d89bf2a9278c6bc1a3b95e7535bc0a6f936fffe1b11bd", + "requestPubKeys": [{ + "key": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1", + "signature": "3044022023b43a8dabfa3a2d615135913021bcd4cfe06739e76cdcec91dedcd93f1c034502200e62c491417874b3ef5d89bf2a9278c6bc1a3b95e7535bc0a6f936fffe1b11bd" + }], + "customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"cz7J7ySbR+GJqWheI9HYyoL+MquLmbUCQDCVS3ZyR24pHiDSq1rh3AxuHxgEIejq7oFeYdQc/eLzJFtTNe2bFm00N6w/hpa3RAm3PYpajfYYn3JH2JvFrCJYckQ=\"}" + }], + "pubKey": "03dcd6c9a8bc5109a62b0273e63cbf2e15bb65698e646d4713c85b2644551ce4f8", + "network": "livenet", + "derivationStrategy": "BIP44", + "addressType": "P2PKH", + "addressManager": { + "version": 2, + "derivationStrategy": "BIP44", + "receiveAddressIndex": 0, + "changeAddressIndex": 0, + "copayerIndex": 2147483647 + }, + "scanStatus": null + } + }, + // post wallets + '8563715db4f4822b4b2a97173093293f8c48e9468de76ef048b0fe3fb846c920': { + "walletId": "65ffeffb-97f2-433d-ae04-8d28c1b96798" + }, + // post copayers + 'fa2ecf7b36e3048da454284902ae3b97ffd9d86d0ccd72d36ff32bb8543cd4c1': { + "copayerId": "e939fdf291091b5413f6682d2f1b7c2c3174face27139ec0e2fc8a9b172c2644", + "wallet": { + "version": "1.0.0", + "createdOn": 1469713979, + "id": "65ffeffb-97f2-433d-ae04-8d28c1b96798", + "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"HGqck9Px9U26IE5uSKrlrp39t8WznEs=\"}", + "m": 1, + "n": 1, + "singleAddress": false, + "status": "complete", + "publicKeyRing": [{ + "xPubKey": "xpub6CtArrqbWKXT1m2aF8nx3ZuDsyNGCFH54HCLxG3QRQuaeB1ciboT2KbVMdy3tzGuzc4A8iMxj4aQKmWjgXEjyfm5b8Vq8XXinRkTx3njjLC", + "requestPubKey": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077" + }], + "copayers": [{ + "version": 2, + "createdOn": 1469713980, + "xPubKey": "xpub6CtArrqbWKXT1m2aF8nx3ZuDsyNGCFH54HCLxG3QRQuaeB1ciboT2KbVMdy3tzGuzc4A8iMxj4aQKmWjgXEjyfm5b8Vq8XXinRkTx3njjLC", + "id": "e939fdf291091b5413f6682d2f1b7c2c3174face27139ec0e2fc8a9b172c2644", + "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"IWqHNixCmrWcWA==\"}", + "requestPubKey": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077", + "signature": "304502210092ca3f8c481639913e2917350a7be9aa2fe84ca1becf3a16de6d3bd1e0c39b93022032df2c871c7f0b414fa83c7920582fbe3e2c83d3db76966d95d7a6002eb57291", + "requestPubKeys": [{ + "key": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077", + "signature": "304502210092ca3f8c481639913e2917350a7be9aa2fe84ca1becf3a16de6d3bd1e0c39b93022032df2c871c7f0b414fa83c7920582fbe3e2c83d3db76966d95d7a6002eb57291" + }], + "customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"Oc30Rr5SMU6qbeSkF6pO+lfd7z7Ywyqhjqzzh6snyonLY34k6SmeLKCIb0rwYLOUBUdvWx3sY05qjYjcm/9xKPyTV8DSxLXc9EP6LE4B0dl1yvehARcFFq6ZcGE=\"}" + }], + "pubKey": "03be9b96960ebef82cb5fd9a0d0cbea17070819c3df6c39ca04b821a2b7642e938", + "network": "livenet", + "derivationStrategy": "BIP44", + "addressType": "P2PKH", + "addressManager": { + "version": 2, + "derivationStrategy": "BIP44", + "receiveAddressIndex": 0, + "changeAddressIndex": 0, + "copayerIndex": 2147483647 + }, + "scanStatus": null + } + } }; // TODO: Read from file beforeEach(function(done) { @@ -67,7 +164,7 @@ describe('disclaimerController', function() { should.exist(ctrl); }); - it('should create the initial profile', function(done) { + it.only('should create the initial profile', function(done) { localStorage.clear(); ctrl.init({ walletPrivKey: 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy', @@ -77,6 +174,6 @@ describe('disclaimerController', function() { mocks.ongoingProcess.set.getCall(1).args[0].should.equal('creatingWallet'); mocks.ongoingProcess.set.getCall(1).args[1].should.equal(false); done(); - }, 100); + }, 10000); }); }); From fb578eaffb0dc678d6a33a924927836eae369f11 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 15:04:09 -0300 Subject: [PATCH 5/8] fix tests --- package.json | 1 - src/js/controllers/disclaimer.js | 2 +- src/js/controllers/import.js | 2 +- src/js/services/localStorage.js | 1 + src/js/services/profileService.js | 10 ++- test/controllers/disclaimer.test.js | 105 ++-------------------------- test/controllers/import.test.js | 7 +- test/helpers.js | 4 ++ 8 files changed, 22 insertions(+), 110 deletions(-) diff --git a/package.json b/package.json index ba88d721e..5fa3a7ac8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", - "grunt": ">=0.4.0", "shelljs": "^0.3.0" }, "scripts": { diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index 261032579..177c82a41 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -11,6 +11,7 @@ angular.module('copayApp.controllers').controller('disclaimerController', var create = function(opts) { opts = opts || {}; $log.debug('Creating profile'); + profileService.create(opts, function(err) { if (err) { $log.warn(err); @@ -30,7 +31,6 @@ angular.module('copayApp.controllers').controller('disclaimerController', } }, 3000); }; - $scope.error = ""; ongoingProcess.set('creatingWallet', false); }); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index b86d06b59..f0337a7de 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -348,9 +348,9 @@ angular.module('copayApp.controllers').controller('importController', }; $scope.setSeedSource = function() { + if (!$scope.seedSource) return; $scope.seedSourceId = $scope.seedSource.id; - $timeout(function() { $rootScope.$apply(); }); diff --git a/src/js/services/localStorage.js b/src/js/services/localStorage.js index 2b629ae2e..8a0cc1610 100644 --- a/src/js/services/localStorage.js +++ b/src/js/services/localStorage.js @@ -8,6 +8,7 @@ angular.module('copayApp.services') var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null); if (isChromeApp && !isNW && !ls) { + $log.info('Using CHROME storage'); ls = chrome.storage.local; } diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 1da3e07b2..46a0eb14a 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -123,6 +123,7 @@ angular.module('copayApp.services') var validationLock = false; root.runValidation = function(client, delay, retryDelay) { + delay = delay || 500; retryDelay = retryDelay || 50; @@ -152,6 +153,7 @@ angular.module('copayApp.services') $log.warn('Key Derivation failed for wallet:' + walletId); storageService.clearLastAddress(walletId, function() {}); } + root.storeProfileIfDirty(); $rootScope.$emit('Local/ValidatingWalletEnded', walletId, isOK); }); @@ -663,9 +665,11 @@ angular.module('copayApp.services') root.createDefaultProfile(opts, function(err, p) { if (err) return cb(err); - root.bindProfile(p, function(err) { - // ignore NONAGREEDDISCLAIMER - storageService.storeNewProfile(p, function(err) { + storageService.storeNewProfile(p, function(err) { + if (err) return cb(err); + root.bindProfile(p, function(err) { + // ignore NONAGREEDDISCLAIMER + if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb(); return cb(err); }); }); diff --git a/test/controllers/disclaimer.test.js b/test/controllers/disclaimer.test.js index 4390806dd..9a8709582 100644 --- a/test/controllers/disclaimer.test.js +++ b/test/controllers/disclaimer.test.js @@ -49,110 +49,13 @@ describe('disclaimerController', function() { "scanStatus": null } }, - - //======================================================== - // post wallets - '3295ba1bcd509b7d42928c071999281f7692caa64df43177bec8a6a8c3fa8927': { - "walletId": "24c40723-c360-498d-a803-a6e1e4ef990d" - }, - // post /v2/wallets/24c40723-c360-498d-a803-a6e1e4ef990d/copayers - '5f109ab9572a69feb0654268b8802afa364d6e8217aeaf851416f0394502e90c': { - "copayerId": "6348201ef06ad5b922065fd4e510152c3da3af1196c0cb8f6e34f6e0494fa4a1", - "wallet": { - "version": "1.0.0", - "createdOn": 1469713357, - "id": "24c40723-c360-498d-a803-a6e1e4ef990d", - "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"DK2ZgZ/k/rr5UfXn4Ht1KAAaRp7Wa5E=\"}", - "m": 1, - "n": 1, - "singleAddress": false, - "status": "complete", - "publicKeyRing": [{ - "xPubKey": "xpub6D1Um62Uho1NDw6jYzgqCzase3L9TNLmCn42YuBzP8Vn4q94LwpNbcv3zpJJAS6BVf8YyKfKKqTt9BG9PBzcCbPouGkkci9qMNXTtZRmtAy", - "requestPubKey": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1" - }], - "copayers": [{ - "version": 2, - "createdOn": 1469713357, - "xPubKey": "xpub6D1Um62Uho1NDw6jYzgqCzase3L9TNLmCn42YuBzP8Vn4q94LwpNbcv3zpJJAS6BVf8YyKfKKqTt9BG9PBzcCbPouGkkci9qMNXTtZRmtAy", - "id": "6348201ef06ad5b922065fd4e510152c3da3af1196c0cb8f6e34f6e0494fa4a1", - "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"Ma1tUjOpLrDtSA==\"}", - "requestPubKey": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1", - "signature": "3044022023b43a8dabfa3a2d615135913021bcd4cfe06739e76cdcec91dedcd93f1c034502200e62c491417874b3ef5d89bf2a9278c6bc1a3b95e7535bc0a6f936fffe1b11bd", - "requestPubKeys": [{ - "key": "03caa96ae18a6805f13851e6e3f08e15d505abb52cfde39427561587f5652245c1", - "signature": "3044022023b43a8dabfa3a2d615135913021bcd4cfe06739e76cdcec91dedcd93f1c034502200e62c491417874b3ef5d89bf2a9278c6bc1a3b95e7535bc0a6f936fffe1b11bd" - }], - "customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"cz7J7ySbR+GJqWheI9HYyoL+MquLmbUCQDCVS3ZyR24pHiDSq1rh3AxuHxgEIejq7oFeYdQc/eLzJFtTNe2bFm00N6w/hpa3RAm3PYpajfYYn3JH2JvFrCJYckQ=\"}" - }], - "pubKey": "03dcd6c9a8bc5109a62b0273e63cbf2e15bb65698e646d4713c85b2644551ce4f8", - "network": "livenet", - "derivationStrategy": "BIP44", - "addressType": "P2PKH", - "addressManager": { - "version": 2, - "derivationStrategy": "BIP44", - "receiveAddressIndex": 0, - "changeAddressIndex": 0, - "copayerIndex": 2147483647 - }, - "scanStatus": null - } - }, - // post wallets - '8563715db4f4822b4b2a97173093293f8c48e9468de76ef048b0fe3fb846c920': { - "walletId": "65ffeffb-97f2-433d-ae04-8d28c1b96798" - }, - // post copayers - 'fa2ecf7b36e3048da454284902ae3b97ffd9d86d0ccd72d36ff32bb8543cd4c1': { - "copayerId": "e939fdf291091b5413f6682d2f1b7c2c3174face27139ec0e2fc8a9b172c2644", - "wallet": { - "version": "1.0.0", - "createdOn": 1469713979, - "id": "65ffeffb-97f2-433d-ae04-8d28c1b96798", - "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"HGqck9Px9U26IE5uSKrlrp39t8WznEs=\"}", - "m": 1, - "n": 1, - "singleAddress": false, - "status": "complete", - "publicKeyRing": [{ - "xPubKey": "xpub6CtArrqbWKXT1m2aF8nx3ZuDsyNGCFH54HCLxG3QRQuaeB1ciboT2KbVMdy3tzGuzc4A8iMxj4aQKmWjgXEjyfm5b8Vq8XXinRkTx3njjLC", - "requestPubKey": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077" - }], - "copayers": [{ - "version": 2, - "createdOn": 1469713980, - "xPubKey": "xpub6CtArrqbWKXT1m2aF8nx3ZuDsyNGCFH54HCLxG3QRQuaeB1ciboT2KbVMdy3tzGuzc4A8iMxj4aQKmWjgXEjyfm5b8Vq8XXinRkTx3njjLC", - "id": "e939fdf291091b5413f6682d2f1b7c2c3174face27139ec0e2fc8a9b172c2644", - "name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"IWqHNixCmrWcWA==\"}", - "requestPubKey": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077", - "signature": "304502210092ca3f8c481639913e2917350a7be9aa2fe84ca1becf3a16de6d3bd1e0c39b93022032df2c871c7f0b414fa83c7920582fbe3e2c83d3db76966d95d7a6002eb57291", - "requestPubKeys": [{ - "key": "032965f65c6f8fefda40ff9ed1aaa66725db2d7e529210e4c5f1a02a66b3253077", - "signature": "304502210092ca3f8c481639913e2917350a7be9aa2fe84ca1becf3a16de6d3bd1e0c39b93022032df2c871c7f0b414fa83c7920582fbe3e2c83d3db76966d95d7a6002eb57291" - }], - "customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"Oc30Rr5SMU6qbeSkF6pO+lfd7z7Ywyqhjqzzh6snyonLY34k6SmeLKCIb0rwYLOUBUdvWx3sY05qjYjcm/9xKPyTV8DSxLXc9EP6LE4B0dl1yvehARcFFq6ZcGE=\"}" - }], - "pubKey": "03be9b96960ebef82cb5fd9a0d0cbea17070819c3df6c39ca04b821a2b7642e938", - "network": "livenet", - "derivationStrategy": "BIP44", - "addressType": "P2PKH", - "addressManager": { - "version": 2, - "derivationStrategy": "BIP44", - "receiveAddressIndex": 0, - "changeAddressIndex": 0, - "copayerIndex": 2147483647 - }, - "scanStatus": null - } - } }; // TODO: Read from file beforeEach(function(done) { + mocks.init(fixtures, 'disclaimerController', { initController: true, - noDisclaimer: true, + noProfile: true, }, done); }); @@ -164,7 +67,7 @@ describe('disclaimerController', function() { should.exist(ctrl); }); - it.only('should create the initial profile', function(done) { + it('should create the initial profile', function(done) { localStorage.clear(); ctrl.init({ walletPrivKey: 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy', @@ -174,6 +77,6 @@ describe('disclaimerController', function() { mocks.ongoingProcess.set.getCall(1).args[0].should.equal('creatingWallet'); mocks.ongoingProcess.set.getCall(1).args[1].should.equal(false); done(); - }, 10000); + }, 100); }); }); diff --git a/test/controllers/import.test.js b/test/controllers/import.test.js index 7d7b8dc2f..b5c21b456 100644 --- a/test/controllers/import.test.js +++ b/test/controllers/import.test.js @@ -90,9 +90,10 @@ describe('importController', function() { scope.bwsurl = null; scope._walletPrivKey = 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy'; - ctrl.setSeedSource(); - ctrl.importMnemonic(fakeForm); - should.not.exist(ctrl.error); + scope.setSeedSource(); + + scope.importMnemonic(fakeForm); + should.not.exist(scope.error); mocks.notification.success.calledOnce.should.equal(true); diff --git a/test/helpers.js b/test/helpers.js index ab3effb29..e202fb9f4 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -226,6 +226,10 @@ mocks.init = function(fixtures, controllerName, opts, done) { done(); }); } else { + if (opts.noProfile){ + return done(); + } + _profileService_.create({ noWallet: true }, function(err) { From 8619abbbe56042f6fb75dc70a40e43cd444bff2f Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 15:11:03 -0300 Subject: [PATCH 6/8] update bwc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5fa3a7ac8..54c4a81a4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "2.10.0", + "bitcore-wallet-client": "2.11.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", From 994f41fbf92e7fc09aa2d361f53f7ff94602fd43 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 15:33:10 -0300 Subject: [PATCH 7/8] update node version for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff6ea90ce..51762742b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - '0.12' + - '4.0' before_install: - npm install -g bower - npm install -g grunt-cli From 1f57a0274604876a8f45e494bde7b1414ae6d5a5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 28 Jul 2016 16:49:18 -0300 Subject: [PATCH 8/8] fix header workaround for mocking requests --- test/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers.js b/test/helpers.js index e202fb9f4..553db161e 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -112,7 +112,7 @@ mocks.init = function(fixtures, controllerName, opts, done) { var headers = JSON.stringify(bwc._getHeaders(method, url, args)); // Fixes BWC version... TODO - headers = headers.replace(/bwc-\d\.\d\.\d/, 'bwc-2.4.0') + headers = headers.replace(/bwc-\d+\.\d+\.\d+/, 'bwc-2.4.0') var x = method + url + JSON.stringify(args) + headers; var sjcl = $delegate.getSJCL(); return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(x));