mirror of https://github.com/BTCPrivate/copay.git
Add controller tests (#4205)
* add walletHome test template * add create test * add fixtures * do not mock parseSecret * better hash * use fixtures for create controller test * add import test * stubs reset * add more controller tests * Remove $state dependency * refactore fixtures + profiles * add backup.js test * update bwc * rm log
This commit is contained in:
parent
335c3f00af
commit
aec2aac47b
|
@ -45,6 +45,8 @@ bwcModule.provider("bwcService", function() {
|
|||
|
||||
service.buildTx = Client.buildTx;
|
||||
service.parseSecret = Client.parseSecret;
|
||||
service.Client = Client;
|
||||
service.config = config;
|
||||
|
||||
service.getUtils = function() {
|
||||
return Client.Utils;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"url": "https://github.com/bitpay/copay/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bitcore-wallet-client": "2.4.0",
|
||||
"bitcore-wallet-client": "https://github.com/bitpay/bitcore-wallet-client#baf7b8e50f53d3a62d0f5804919f0f0218872daf",
|
||||
"express": "^4.11.2",
|
||||
"fs": "0.0.2",
|
||||
"grunt": "^0.4.5",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupController',
|
||||
function($rootScope, $scope, $timeout, $log, $state, $compile, go, lodash, profileService, gettext, bwcService, bwsError, walletService) {
|
||||
function($rootScope, $scope, $timeout, $document, $log, $state, $compile, go, lodash, profileService, gettext, bwcService, bwsError, walletService) {
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
|
@ -101,15 +101,15 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
}
|
||||
|
||||
function resetAllButtons() {
|
||||
document.getElementById('addWord').innerHTML = '';
|
||||
var nodes = document.getElementById("buttons").getElementsByTagName('button');
|
||||
$document.getElementById('addWord').innerHTML = '';
|
||||
var nodes = $document.getElementById("buttons").getElementsByTagName('button');
|
||||
lodash.each(nodes, function(n) {
|
||||
document.getElementById(n.id).disabled = false;
|
||||
$document.getElementById(n.id).disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
self.enableButton = function(word) {
|
||||
document.getElementById(word).disabled = false;
|
||||
$document.getElementById(word).disabled = false;
|
||||
lodash.remove(customWords, function(v) {
|
||||
return v == word;
|
||||
});
|
||||
|
@ -120,7 +120,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
index: index,
|
||||
word: word
|
||||
};
|
||||
document.getElementById(index + word).disabled = true;
|
||||
$document.getElementById(index + word).disabled = true;
|
||||
customWords.push(element);
|
||||
self.addButton(index, word);
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
var btnhtml = '<button class="button radius tiny words" ng-disabled="wordsC.disableButtons"' +
|
||||
'data-ng-click="wordsC.removeButton($event)" id="_' + index + word + '" > ' + word + ' </button>';
|
||||
var temp = $compile(btnhtml)($scope);
|
||||
angular.element(document.getElementById('addWord')).append(temp);
|
||||
angular.element($document.getElementById('addWord')).append(temp);
|
||||
self.shouldContinue();
|
||||
}
|
||||
|
||||
self.removeButton = function(event) {
|
||||
var id = (event.target.id);
|
||||
document.getElementById(id).remove();
|
||||
$document.getElementById(id).remove();
|
||||
self.enableButton(id.substring(1));
|
||||
lodash.remove(customWords, function(d) {
|
||||
return d.index == id.substring(1, 3);
|
||||
|
|
|
@ -96,6 +96,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
myName: $scope.totalCopayers > 1 ? $scope.myName : null,
|
||||
networkName: $scope.isTestnet ? 'testnet' : 'livenet',
|
||||
bwsurl: $scope.bwsurl,
|
||||
walletPrivKey: $scope._walletPrivKey, // Only for testing
|
||||
};
|
||||
var setSeed = self.seedSourceId == 'set';
|
||||
if (setSeed) {
|
||||
|
@ -159,6 +160,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
this._create = function(opts) {
|
||||
self.loading = true;
|
||||
$timeout(function() {
|
||||
|
||||
profileService.createWallet(opts, function(err, walletId) {
|
||||
self.loading = false;
|
||||
if (err) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, latestReleaseService, bwcService, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, coinbaseService, isMobile, addressbookService, walletService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, latestReleaseService, bwcService, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, isChromeApp, bwsError, txFormatService, uxLanguage, glideraService, coinbaseService, isMobile, addressbookService, walletService) {
|
||||
var self = this;
|
||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||
var errors = bwcService.getErrors();
|
||||
|
@ -156,7 +156,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
$log.debug('Wallet not complete BEFORE update... redirecting');
|
||||
go.path('copayers');
|
||||
} else {
|
||||
if ($state.is('copayers')) {
|
||||
if (go.is('copayers')) {
|
||||
$log.debug('Wallet Complete BEFORE update... redirect to home');
|
||||
go.walletHome();
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
$log.debug('Wallet not complete after update... redirecting');
|
||||
go.path('copayers');
|
||||
} else {
|
||||
if ($state.is('copayers')) {
|
||||
if (go.is('copayers')) {
|
||||
$log.debug('Wallet Complete after update... redirect to home');
|
||||
go.walletHome();
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
}, 300);
|
||||
}
|
||||
|
||||
if (!self.tab || !$state.is('walletHome'))
|
||||
if (!self.tab || go.is('walletHome'))
|
||||
self.tab = 'walletHome';
|
||||
|
||||
var changeTab = function() {
|
||||
|
@ -235,7 +235,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
$rootScope.$emit('Local/TabChanged', tab);
|
||||
};
|
||||
|
||||
if (switchState && !$state.is('walletHome')) {
|
||||
if (switchState && go.is('walletHome')) {
|
||||
go.path('walletHome', function() {
|
||||
changeTab();
|
||||
});
|
||||
|
|
|
@ -84,7 +84,9 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
opts.passphrase = form.createPassphrase.$modelValue;
|
||||
}
|
||||
|
||||
|
||||
if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) {
|
||||
|
||||
this.error = gettext('Please enter the wallet recovery phrase');
|
||||
return;
|
||||
}
|
||||
|
@ -93,6 +95,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
var account = $scope.account;
|
||||
if (!account || account < 1) {
|
||||
this.error = gettext('Invalid account number');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,6 +117,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
self._join(opts);
|
||||
});
|
||||
} else {
|
||||
|
||||
self._join(opts);
|
||||
}
|
||||
};
|
||||
|
@ -121,6 +125,8 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
this._join = function(opts) {
|
||||
self.loading = true;
|
||||
$timeout(function() {
|
||||
|
||||
console.log('[join.js.124]', opts); //TODO
|
||||
profileService.joinWallet(opts, function(err) {
|
||||
if (err) {
|
||||
self.loading = false;
|
||||
|
|
|
@ -38,6 +38,10 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
|||
}
|
||||
};
|
||||
|
||||
root.is = function(name) {
|
||||
return $state.is(name);
|
||||
};
|
||||
|
||||
root.path = function(path, cb) {
|
||||
$state.transitionTo(path)
|
||||
.then(function() {
|
||||
|
|
|
@ -148,9 +148,8 @@ angular.module('copayApp.services')
|
|||
root.isDisclaimerAccepted(function(val) {
|
||||
if (!val) {
|
||||
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
} else {
|
||||
return cb();
|
||||
}
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -306,7 +305,8 @@ angular.module('copayApp.services')
|
|||
if (err) return cb(err);
|
||||
|
||||
walletClient.createWallet(opts.name, opts.myName || 'me', opts.m, opts.n, {
|
||||
network: opts.networkName
|
||||
network: opts.networkName,
|
||||
walletPrivKey: opts.walletPrivKey,
|
||||
}, function(err, secret) {
|
||||
if (err) return bwsError.cb(err, gettext('Error creating wallet'), cb);
|
||||
|
||||
|
@ -571,6 +571,7 @@ angular.module('copayApp.services')
|
|||
if (err) return cb(err);
|
||||
|
||||
root.bindProfile(p, function(err) {
|
||||
// ignore NONAGREEDDISCLAIMER
|
||||
storageService.storeNewProfile(p, function(err) {
|
||||
return cb(err);
|
||||
});
|
||||
|
@ -588,7 +589,6 @@ angular.module('copayApp.services')
|
|||
|
||||
root.isDisclaimerAccepted = function(cb) {
|
||||
var disclaimerAccepted = root.profile && root.profile.disclaimerAccepted;
|
||||
|
||||
if (disclaimerAccepted)
|
||||
return cb(true);
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
describe('Backup Controller', function() {
|
||||
|
||||
var walletService;
|
||||
|
||||
describe('Incomplete wallet', function() {
|
||||
beforeEach(function(done) {
|
||||
mocks.init(FIXTURES, 'backupController', {
|
||||
loadProfile: PROFILE.incomplete2of2,
|
||||
}, done);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
it('should set the mnemonic incomplete wallets', function(done) {
|
||||
should.exist(ctrl);
|
||||
ctrl.mnemonicWords.should.deep.equal('dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero'.split(' '));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Complete 1-1 wallet', function() {
|
||||
beforeEach(function(done) {
|
||||
mocks.init(FIXTURES, 'backupController', {
|
||||
loadProfile: PROFILE.testnet1of1,
|
||||
}, done);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
it('should not set the mnemonic for complete wallets', function() {
|
||||
ctrl.mnemonicWords.should.deep.equal('cheese where alarm job conduct donkey license pave congress pepper fence current'.split(' '));
|
||||
});
|
||||
|
||||
it('should set main wallet info', function(done) {
|
||||
ctrl.walletName.should.equal('kk');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
describe('copayers', function() {
|
||||
|
||||
var walletService;
|
||||
var fixtures = {};
|
||||
|
||||
|
||||
beforeEach(function(done){
|
||||
mocks.init(fixtures, 'copayersController', {}, done);
|
||||
})
|
||||
|
||||
afterEach(function(done){
|
||||
mocks.clear({}, done);
|
||||
})
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,180 @@
|
|||
describe('createController', function() {
|
||||
var fixtures = {
|
||||
|
||||
// createWallet 1-1
|
||||
'56db6f58f2c212591afb4d508d03e5fb40bb786f23dc56c43b98bde42dc513e5': {
|
||||
"walletId": "267bfa75-5575-4af7-8aa3-f5186bc99262"
|
||||
},
|
||||
// join ^
|
||||
'd2f00a570de17f52fcda4b1b4b4ed1bc688a3b33c193b71630c3183dab70e6ec': {
|
||||
"copayerId": "a9dcee10fe9c611300e6c7926ece20780f89b9a98baaa342928038b5503ed929",
|
||||
"wallet": {
|
||||
"version": "1.0.0",
|
||||
"createdOn": 1463488747,
|
||||
"id": "267bfa75-5575-4af7-8aa3-f5186bc99262",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"70OA+k4+xTPxim+QSdDtA5/Cf055\"}",
|
||||
"m": 1,
|
||||
"n": 1,
|
||||
"status": "complete",
|
||||
"publicKeyRing": [{
|
||||
"xPubKey": "xpub6DRjAgkh3vGTWDcEmDp4TPwy48Nu8yrp6swCEdCCLL615CgnZon7r3vXYr8LYibMLJh5DriGSito1FRBwVoBkjD1ZWG4dmgiC935wLj3nQC",
|
||||
"requestPubKey": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458"
|
||||
}],
|
||||
"copayers": [{
|
||||
"version": 2,
|
||||
"createdOn": 1463490295,
|
||||
"xPubKey": "xpub6DRjAgkh3vGTWDcEmDp4TPwy48Nu8yrp6swCEdCCLL615CgnZon7r3vXYr8LYibMLJh5DriGSito1FRBwVoBkjD1ZWG4dmgiC935wLj3nQC",
|
||||
"id": "a9dcee10fe9c611300e6c7926ece20780f89b9a98baaa342928038b5503ed929",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"wwZd+2LQgYR6cA==\"}",
|
||||
"requestPubKey": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458",
|
||||
"signature": "3044022042e069126a42f1b9b498c315a825ef4fc9f4214156442651e4fef5c7678245e702205936045d7b22baa36ba36ef827cc3e5d542d57d9a1afb3a54080d12f0b95c67e",
|
||||
"requestPubKeys": [{
|
||||
"key": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458",
|
||||
"signature": "3044022042e069126a42f1b9b498c315a825ef4fc9f4214156442651e4fef5c7678245e702205936045d7b22baa36ba36ef827cc3e5d542d57d9a1afb3a54080d12f0b95c67e"
|
||||
}],
|
||||
"customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"1Wjf2KvFkd5k0ypiiSNkSVXk7zdBOiTeCrwzPBI7fMQ/VqXUzrSB6gMGs9jISr+MvCaL1GJIXjaMnlQZNMR0lx/Pd1c6R/nKGBdHjKh0mlI=\"}"
|
||||
}],
|
||||
"pubKey": "026d95bb5cc2a30c19e22379ae78b4757aaa2dd0ccbd15a1db054fb50cb98ed361",
|
||||
"network": "livenet",
|
||||
"derivationStrategy": "BIP44",
|
||||
"addressType": "P2PKH",
|
||||
"addressManager": {
|
||||
"version": 2,
|
||||
"derivationStrategy": "BIP44",
|
||||
"receiveAddressIndex": 0,
|
||||
"changeAddressIndex": 0,
|
||||
"copayerIndex": 2147483647
|
||||
},
|
||||
"scanStatus": null
|
||||
}
|
||||
},
|
||||
|
||||
//createWallet 2-2
|
||||
'e46ef870b70e6deca6bbfa61bd0d83b0dc5b712402538b0dabcd0d4f038b0eba': {
|
||||
"walletId": "7bd8d22f-d132-43e1-b259-d5b430752553"
|
||||
},
|
||||
|
||||
// join ^
|
||||
'2df76b91e0080f1552926b7d3ce5dd99db054bc4dfce309d8455cab5d9a93ad4': {
|
||||
"copayerId": "3d4eb9b439eee1b2b73cf792eda52e420f4665109c7234a50cf3cdbf296ea8fb",
|
||||
"wallet": {
|
||||
"version": "1.0.0",
|
||||
"createdOn": 1463511645,
|
||||
"id": "7bd8d22f-d132-43e1-b259-d5b430752553",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"70OA+k4+xTPxim+QSdDtA5/Cf055\"}",
|
||||
"m": 2,
|
||||
"n": 2,
|
||||
"status": "pending",
|
||||
"publicKeyRing": [],
|
||||
"copayers": [{
|
||||
"version": 2,
|
||||
"createdOn": 1463511988,
|
||||
"xPubKey": "xpub6CkPnrzSUp9qzBVM3hpo4oS2JKC6GJq6brE1yW59QrnhDpvkFLakpxUGRGXH62fiXb5S2VbnD4h2DLoCMfSkwfonbNgNYTJw9Ko5SqWEqCR",
|
||||
"id": "3d4eb9b439eee1b2b73cf792eda52e420f4665109c7234a50cf3cdbf296ea8fb",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"wwZd+2LQgYR6cA==\"}",
|
||||
"requestPubKey": "022941a5ecb8c7224f812ad6b03bd1c9bb77861080b21703eabe18ef9a72b48e72",
|
||||
"signature": "30440220521623cf346f667658c00f1dea113407f23cecf02932c7dcb4b8bf35f1836b7a02202c77b8e4260942f4e13a58faae1f92e1130bae1157492056347e66741150eb2c",
|
||||
"requestPubKeys": [{
|
||||
"key": "022941a5ecb8c7224f812ad6b03bd1c9bb77861080b21703eabe18ef9a72b48e72",
|
||||
"signature": "30440220521623cf346f667658c00f1dea113407f23cecf02932c7dcb4b8bf35f1836b7a02202c77b8e4260942f4e13a58faae1f92e1130bae1157492056347e66741150eb2c"
|
||||
}],
|
||||
"customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"YJqN/LtkCY0cOB235RtbGEAY7wKGT0cUUpAvUeLkAUKz3/1axsYZtnG+PU0jHtwQvgmKNLkNcXNR60K+tyRpU0TG1z8pyx4gKwwD3Dt7KzA=\"}"
|
||||
}],
|
||||
"pubKey": "026d95bb5cc2a30c19e22379ae78b4757aaa2dd0ccbd15a1db054fb50cb98ed361",
|
||||
"network": "livenet",
|
||||
"derivationStrategy": "BIP44",
|
||||
"addressType": "P2SH",
|
||||
"addressManager": {
|
||||
"version": 2,
|
||||
"derivationStrategy": "BIP44",
|
||||
"receiveAddressIndex": 0,
|
||||
"changeAddressIndex": 0,
|
||||
"copayerIndex": 2147483647
|
||||
},
|
||||
"scanStatus": null
|
||||
}
|
||||
},
|
||||
}; // TODO: Read from file
|
||||
|
||||
beforeEach(function(done){
|
||||
mocks.init(fixtures, 'createController', {}, done);
|
||||
})
|
||||
|
||||
|
||||
afterEach(function(done){
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
|
||||
it('should create a 1-1 wallet from mnemonic', function(done) {
|
||||
var fakeForm = {};
|
||||
|
||||
// FROM DATA
|
||||
scope.seedSource = {
|
||||
id: 'set'
|
||||
};
|
||||
scope.requiredCopayers = 1;
|
||||
scope.totalCopayers = 1
|
||||
scope.walletName = 'A test wallet';
|
||||
scope.isTestnet = false;
|
||||
scope.bwsurl = null;
|
||||
scope.privateKey = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
|
||||
scope._walletPrivKey = 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy';
|
||||
|
||||
ctrl.setSeedSource();
|
||||
ctrl.create(fakeForm);
|
||||
|
||||
should.not.exist(ctrl.error);
|
||||
mocks.go.walletHome.calledOnce.should.equal(true);
|
||||
|
||||
// check resulting profile
|
||||
storageService.getProfile(function(err, profile) {
|
||||
should.not.exist(err);
|
||||
var c = profile.credentials[0];
|
||||
c.network.should.equal('livenet');
|
||||
// from test vectors from https://dcpos.github.io/bip39/
|
||||
c.xPrivKey.should.equal('xprv9s21ZrQH143K2x4gnzRB1eZDq92Uuvy9CXbvgQGdvykXZ9mkkot6LBjzDpgaAfvzkuxJe9JKJXQ38VoPutxvACA5MsyoBs5UyQ4HZKGshGs');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should create an incomplete 2-2 wallet from mnemonic', function(done) {
|
||||
var fakeForm = {};
|
||||
|
||||
// FROM DATA
|
||||
scope.seedSource = {
|
||||
id: 'set'
|
||||
};
|
||||
scope.requiredCopayers = 2;
|
||||
scope.totalCopayers = 2;
|
||||
scope.walletName = 'A test wallet';
|
||||
scope.isTestnet = false;
|
||||
scope.bwsurl = null;
|
||||
scope.privateKey = 'dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero';
|
||||
scope._walletPrivKey = 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy';
|
||||
|
||||
ctrl.setSeedSource();
|
||||
ctrl.create(fakeForm);
|
||||
|
||||
should.not.exist(ctrl.error);
|
||||
mocks.go.walletHome.calledOnce.should.equal(true, 'Go Wallet Home Called');
|
||||
|
||||
// check resulting profile
|
||||
storageService.getProfile(function(err, profile) {
|
||||
should.not.exist(err);
|
||||
var c = profile.credentials[0];
|
||||
c.network.should.equal('livenet');
|
||||
// from test vectors from https://dcpos.github.io/bip39/
|
||||
c.xPrivKey.should.equal('xprv9s21ZrQH143K27bhzfejhNcitEAJgLKCfdLxwhr1FLu43FLqLwscAxXgmkucpF4k8eGmepSctkiQDbcR98Qd1bzSeDuR9jeyQAQEanPT2A4');
|
||||
// m/44'/0'/0'
|
||||
c.xPubKey.should.equal('xpub6CkPnrzSUp9qzBVM3hpo4oS2JKC6GJq6brE1yW59QrnhDpvkFLakpxUGRGXH62fiXb5S2VbnD4h2DLoCMfSkwfonbNgNYTJw9Ko5SqWEqCR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,110 @@
|
|||
describe('importController', function() {
|
||||
var walletService;
|
||||
var storeProfile;
|
||||
|
||||
var fixtures = {
|
||||
'4599136eff6deb4c9c78043fa84113617a16d75c45920d662305f6227ae8f0a0': {
|
||||
"wallet": {
|
||||
"version": "1.0.0",
|
||||
"createdOn": 1463488747,
|
||||
"id": "267bfa75-5575-4af7-8aa3-f5186bc99262",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"70OA+k4+xTPxim+QSdDtA5/Cf055\"}",
|
||||
"m": 1,
|
||||
"n": 1,
|
||||
"status": "complete",
|
||||
"publicKeyRing": [{
|
||||
"xPubKey": "xpub6DRjAgkh3vGTWDcEmDp4TPwy48Nu8yrp6swCEdCCLL615CgnZon7r3vXYr8LYibMLJh5DriGSito1FRBwVoBkjD1ZWG4dmgiC935wLj3nQC",
|
||||
"requestPubKey": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458"
|
||||
}],
|
||||
"copayers": [{
|
||||
"version": 2,
|
||||
"createdOn": 1463490295,
|
||||
"id": "a9dcee10fe9c611300e6c7926ece20780f89b9a98baaa342928038b5503ed929",
|
||||
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"wwZd+2LQgYR6cA==\"}",
|
||||
"xPubKey": "xpub6DRjAgkh3vGTWDcEmDp4TPwy48Nu8yrp6swCEdCCLL615CgnZon7r3vXYr8LYibMLJh5DriGSito1FRBwVoBkjD1ZWG4dmgiC935wLj3nQC",
|
||||
"requestPubKey": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458",
|
||||
"signature": "3044022042e069126a42f1b9b498c315a825ef4fc9f4214156442651e4fef5c7678245e702205936045d7b22baa36ba36ef827cc3e5d542d57d9a1afb3a54080d12f0b95c67e",
|
||||
"requestPubKeys": [{
|
||||
"key": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458",
|
||||
"signature": "3044022042e069126a42f1b9b498c315a825ef4fc9f4214156442651e4fef5c7678245e702205936045d7b22baa36ba36ef827cc3e5d542d57d9a1afb3a54080d12f0b95c67e"
|
||||
}],
|
||||
"customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"1Wjf2KvFkd5k0ypiiSNkSVXk7zdBOiTeCrwzPBI7fMQ/VqXUzrSB6gMGs9jISr+MvCaL1GJIXjaMnlQZNMR0lx/Pd1c6R/nKGBdHjKh0mlI=\"}"
|
||||
}],
|
||||
"pubKey": "026d95bb5cc2a30c19e22379ae78b4757aaa2dd0ccbd15a1db054fb50cb98ed361",
|
||||
"network": "livenet",
|
||||
"derivationStrategy": "BIP44",
|
||||
"addressType": "P2PKH",
|
||||
"addressManager": {
|
||||
"version": 2,
|
||||
"derivationStrategy": "BIP44",
|
||||
"receiveAddressIndex": 0,
|
||||
"changeAddressIndex": 0,
|
||||
"copayerIndex": 2147483647
|
||||
},
|
||||
"scanStatus": null
|
||||
},
|
||||
"preferences": {},
|
||||
"pendingTxps": [],
|
||||
"balance": {
|
||||
"totalAmount": 0,
|
||||
"lockedAmount": 0,
|
||||
"totalConfirmedAmount": 0,
|
||||
"lockedConfirmedAmount": 0,
|
||||
"availableAmount": 0,
|
||||
"availableConfirmedAmount": 0,
|
||||
"byAddress": [],
|
||||
"totalBytesToSendMax": 0,
|
||||
"totalBytesToSendConfirmedMax": 0
|
||||
}
|
||||
}
|
||||
|
||||
}; // TODO: Read from file
|
||||
|
||||
beforeEach(function(done){
|
||||
mocks.init(fixtures, 'importController', {}, done);
|
||||
})
|
||||
|
||||
afterEach(function(done){
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
|
||||
it('should import a 1-1 wallet from mnemonic', function(done) {
|
||||
var fakeForm = {
|
||||
words: {
|
||||
$modelValue: 'legal winner thank year wave sausage worth useful legal winner thank yellow'
|
||||
},
|
||||
passphrase: {}
|
||||
};
|
||||
|
||||
// FROM DATA
|
||||
scope.seedSource = {
|
||||
id: 'set'
|
||||
};
|
||||
scope.bwsurl = null;
|
||||
scope._walletPrivKey = 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy';
|
||||
|
||||
ctrl.setSeedSource();
|
||||
ctrl.importMnemonic(fakeForm);
|
||||
should.not.exist(ctrl.error);
|
||||
|
||||
mocks.notification.success.calledOnce.should.equal(true);
|
||||
|
||||
// mocks.go.walletHome.calledOnce.should.equal(true);
|
||||
|
||||
// check resulting profile
|
||||
storageService.getProfile(function(err, profile) {
|
||||
should.not.exist(err);
|
||||
var c = profile.credentials[0];
|
||||
c.network.should.equal('livenet');
|
||||
// from test vectors from https://dcpos.github.io/bip39/
|
||||
c.xPrivKey.should.equal('xprv9s21ZrQH143K2x4gnzRB1eZDq92Uuvy9CXbvgQGdvykXZ9mkkot6LBjzDpgaAfvzkuxJe9JKJXQ38VoPutxvACA5MsyoBs5UyQ4HZKGshGs');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,71 @@
|
|||
describe('index', function() {
|
||||
|
||||
var walletService;
|
||||
|
||||
|
||||
describe('Incomplete wallet', function() {
|
||||
beforeEach(function(done) {
|
||||
mocks.init(FIXTURES, 'indexController', {
|
||||
loadProfile: PROFILE.incomplete2of2,
|
||||
initController: true,
|
||||
}, done);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
it('should set the invitation code for incomplete wallets', function(done) {
|
||||
should.exist(ctrl);
|
||||
|
||||
ctrl.walletSecret.should.equal('GJ1A8mopdW7wPNWGVksqwQKz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXyL');
|
||||
// should redirect to copayers
|
||||
mocks.go.path.getCall(0).args[0].should.equal('copayers');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Complete 1-1 wallet', function() {
|
||||
beforeEach(function(done) {
|
||||
mocks.init(FIXTURES, 'indexController', {
|
||||
loadProfile: PROFILE.testnet1of1,
|
||||
initController: true,
|
||||
}, done);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
it('should not set the invitation code for complete wallets', function() {
|
||||
// should redirect to copayers
|
||||
mocks.go.path.callCount.should.equal(0);
|
||||
should.not.exist(ctrl.walletSecret);
|
||||
});
|
||||
|
||||
it('should set main wallet info', function(done) {
|
||||
ctrl.walletName.should.equal('kk');
|
||||
ctrl.totalBalanceSat.should.equal(1847686);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set information for receive tab', function(done) {
|
||||
ctrl.tab.should.equal('walletHome');
|
||||
ctrl.setTab('receive');
|
||||
ctrl.tab.should.equal('receive');
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('should updates remote preferences', function(done) {
|
||||
ctrl.updateRemotePreferences({}, function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -0,0 +1,72 @@
|
|||
describe('joinController', function() {
|
||||
|
||||
var walletService;
|
||||
|
||||
var fakeNotification = {};
|
||||
|
||||
|
||||
|
||||
mocks.init({}, 'joinController');
|
||||
|
||||
// Init config
|
||||
beforeEach(function(done) {
|
||||
inject(function($rootScope, $controller, _configService_, _profileService_) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
_configService_.get(function() {
|
||||
join = $controller('joinController', {
|
||||
$scope: scope,
|
||||
$modal: mocks.fakeModal,
|
||||
notification: fakeNotification,
|
||||
configService: _configService_,
|
||||
profileService: _profileService_,
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
it.skip('should be defined', function() {
|
||||
should.exist(join);
|
||||
});
|
||||
|
||||
// // Get html template from cache
|
||||
// beforeEach(inject(function($templateCache) {
|
||||
// viewHtml = $templateCache.get("some/valid/templateUrl");
|
||||
// }));
|
||||
// // beforeEach(inject(function(_$compile_, _$rootScope_){
|
||||
// $compile = _$compile_;
|
||||
// $rootScope = _$rootScope_;
|
||||
//
|
||||
// $scope = $rootScope.$new();
|
||||
// $scope.user = {};
|
||||
// $scope.logout = sinon.stub();
|
||||
// dropdownElement = angular.element(viewHtml);
|
||||
// }));
|
||||
|
||||
it.skip('should join a wallet once the form is submitted', function(done) {
|
||||
// View's joinForm is not available
|
||||
//join.onQrCodeScanned('aQRCode');
|
||||
var fakeForm = {
|
||||
secret: {
|
||||
$modelValue: 'anInvitationCode'
|
||||
},
|
||||
myName: {
|
||||
$modelValue: 'myCopayerName'
|
||||
},
|
||||
bwsurl: 'aFakeURL',
|
||||
createPassphrase: {
|
||||
$modelValue: null
|
||||
},
|
||||
};
|
||||
join.join(fakeForm);
|
||||
|
||||
should.not.exist(join.error);
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
describe('walletHome', function() {
|
||||
|
||||
var walletService;
|
||||
var fixtures = {};
|
||||
|
||||
|
||||
beforeEach(function(done){
|
||||
mocks.init(fixtures, 'walletHomeController', {}, done);
|
||||
})
|
||||
|
||||
afterEach(function(done){
|
||||
mocks.clear({}, done);
|
||||
});
|
||||
|
||||
|
||||
it('should be defined', function() {
|
||||
should.exist(ctrl);
|
||||
});
|
||||
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,234 @@
|
|||
var mocks = {};
|
||||
|
||||
// UI-Router mock from
|
||||
// https://gist.github.com/bmwant/4c8e5fee7a539dba69ace42b617d79c3
|
||||
mocks.$state = function($q) {
|
||||
this.expectedTransitions = [];
|
||||
this.transitionTo = function(stateName) {
|
||||
if (this.expectedTransitions.length > 0) {
|
||||
var expectedState = this.expectedTransitions.shift();
|
||||
if (expectedState !== stateName) {
|
||||
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName);
|
||||
}
|
||||
} else {
|
||||
throw Error("No more transitions were expected! Tried to transition to " + stateName);
|
||||
}
|
||||
console.log("Mock transition to: " + stateName);
|
||||
this.current = stateName;
|
||||
var deferred = $q.defer();
|
||||
var promise = deferred.promise;
|
||||
deferred.resolve();
|
||||
return promise;
|
||||
};
|
||||
|
||||
this.is = function(name) {
|
||||
console.log('[helpers.js.24:name:]', name); //TODO
|
||||
return this.current == name;
|
||||
};
|
||||
this.go = this.transitionTo;
|
||||
this.expectTransitionTo = function(stateName) {
|
||||
this.expectedTransitions.push(stateName);
|
||||
};
|
||||
|
||||
this.ensureAllTransitionsHappened = function() {
|
||||
if (this.expectedTransitions.length > 0) {
|
||||
throw Error("Not all transitions happened!");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
mocks.$timeout = function(cb) {
|
||||
return cb();
|
||||
};
|
||||
|
||||
mocks.modal = function() {};
|
||||
|
||||
|
||||
mocks.setProfile = function(profile) {};
|
||||
/*
|
||||
* opts
|
||||
*/
|
||||
|
||||
var getElements = sinon.stub();
|
||||
getElements.returns([]);
|
||||
|
||||
var getElement = sinon.stub();
|
||||
getElement.returns({
|
||||
getElementsByTagName: getElement,
|
||||
});
|
||||
|
||||
mocks.$document = {
|
||||
getElementById: getElement,
|
||||
};
|
||||
|
||||
mocks.init = function(fixtures, controllerName, opts, done) {
|
||||
console.log(' * Mock init()');
|
||||
opts = opts || {};
|
||||
should.exist(controllerName, 'Provide the name of the Controller to mocks.init()');
|
||||
|
||||
mocks.go = {};
|
||||
mocks.go.walletHome = sinon.stub();
|
||||
mocks.go.path = sinon.stub();
|
||||
mocks.go.is = function(name) {
|
||||
return mocks.go.current == name
|
||||
};
|
||||
|
||||
mocks.notification = {
|
||||
success: sinon.stub(),
|
||||
};
|
||||
|
||||
angular.module('stateMock', []);
|
||||
angular.module('stateMock').service("$state", mocks.$state.bind());
|
||||
|
||||
module('ngLodash');
|
||||
module('gettext');
|
||||
module('bwcModule', function($provide) {
|
||||
$provide.decorator('bwcService', function($delegate, lodash) {
|
||||
var getClient = $delegate.getClient;
|
||||
var config = $delegate.config;
|
||||
|
||||
// Fix Encryption IVs
|
||||
var utils = $delegate.getUtils();
|
||||
utils.SJCL.iv = 'BZQVWAP6d1e4G8Fq1rQKbA==';
|
||||
|
||||
$delegate.getClient = function(walletData) {
|
||||
|
||||
var bwc = new $delegate.Client({
|
||||
baseUrl: config.baseUrl,
|
||||
verbose: config.verbose,
|
||||
transports: config.transports
|
||||
});
|
||||
if (walletData)
|
||||
bwc.import(walletData);
|
||||
|
||||
function createHash(method, url, args) {
|
||||
var headers = JSON.stringify(bwc._getHeaders(method, url, args));
|
||||
var x = method + url + JSON.stringify(args) + headers;
|
||||
var sjcl = $delegate.getSJCL();
|
||||
return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(x));
|
||||
};
|
||||
|
||||
bwc._originalRequest = bwc._doRequest;
|
||||
|
||||
bwc._doGetRequest = function(url, cb) {
|
||||
url += url.indexOf('?') > 0 ? '&' : '?';
|
||||
url += 'r=' + 69321;
|
||||
return this._doRequest('get', url, {}, cb);
|
||||
};
|
||||
|
||||
|
||||
// Use fixtures
|
||||
bwc._doRequest = function(method, url, args, cb2) {
|
||||
|
||||
// find fixed response:
|
||||
var hash = createHash(method, url, args);
|
||||
if (lodash.isUndefined(fixtures[hash])) {
|
||||
console.log('##### UNDEFINED FIXTURED ####:', hash); //TODO
|
||||
console.log('##### method:', method); //TODO
|
||||
console.log('##### url :', url); //TODO
|
||||
console.log('##### args :', JSON.stringify(args)); //TODO
|
||||
console.log('##### header:', JSON.stringify(bwc._getHeaders(method, url, args)));
|
||||
|
||||
var oldURL = bwc.baseURL;
|
||||
bwc.baseURL = 'http://localhost:3232/bws/api';
|
||||
|
||||
console.log('##### running local: to http://localhost:3232/bws/api');
|
||||
bwc._originalRequest(method, url, args, function(err, response) {
|
||||
console.log("### RESPONSE: " + hash + "\n", JSON.stringify(response)); //TODO
|
||||
bwc.baseURL = oldURL;
|
||||
return cb2(null, response);
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('Using fixture: ' + hash.substr(0, 6) + ' for: ' + url);
|
||||
return cb2(null, fixtures[hash]);
|
||||
}
|
||||
};
|
||||
|
||||
return bwc;
|
||||
};
|
||||
return $delegate;
|
||||
});
|
||||
});
|
||||
|
||||
module('angularMoment');
|
||||
module('stateMock');
|
||||
module('copayApp.services', {
|
||||
$modal: mocks.modal,
|
||||
$timeout: mocks.$timeout,
|
||||
$state: mocks.$state,
|
||||
});
|
||||
module('copayApp.controllers');
|
||||
|
||||
inject(function($rootScope, $controller, $injector, _configService_, _profileService_, _storageService_) {
|
||||
scope = $rootScope.$new();
|
||||
storageService = _storageService_;
|
||||
|
||||
// Set up the mock http service responses
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
|
||||
// backend definition common for all tests
|
||||
$httpBackend.when('GET', 'https://bitpay.com/api/rates')
|
||||
.respond({
|
||||
code: "BTC",
|
||||
name: "Bitcoin",
|
||||
rate: 1
|
||||
}, {
|
||||
code: "USD",
|
||||
name: "US Dollar",
|
||||
rate: 452.92
|
||||
});
|
||||
|
||||
_configService_.get(function() {
|
||||
function startController() {
|
||||
ctrl = $controller(controllerName, {
|
||||
$scope: scope,
|
||||
$modal: mocks.modal,
|
||||
notification: mocks.notification,
|
||||
configService: _configService_,
|
||||
profileService: _profileService_,
|
||||
go: mocks.go,
|
||||
$document: mocks.$document,
|
||||
});
|
||||
};
|
||||
|
||||
if (opts.initController)
|
||||
startController();
|
||||
|
||||
if (opts.loadProfile) {
|
||||
|
||||
localStorage.setItem('profile', JSON.stringify(opts.loadProfile));
|
||||
|
||||
_profileService_.loadAndBindProfile(function(err) {
|
||||
should.not.exist(err, err);
|
||||
if (!opts.initController)
|
||||
startController();
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
_profileService_.create({
|
||||
noWallet: true
|
||||
}, function(err) {
|
||||
should.not.exist(err, err);
|
||||
_profileService_.setDisclaimerAccepted(function() {
|
||||
if (!opts.initController)
|
||||
startController();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
mocks.clear = function(opts, done) {
|
||||
opts = opts || {};
|
||||
|
||||
if (!opts.keepStorage) {
|
||||
// Adds walletService's module dependencies
|
||||
console.log(' * deleting localstorage');
|
||||
localStorage.clear();
|
||||
}
|
||||
|
||||
done();
|
||||
};
|
|
@ -10,7 +10,7 @@ module.exports = function(config) {
|
|||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha', 'chai'],
|
||||
frameworks: ['mocha', 'chai', 'sinon'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
|
@ -35,6 +35,7 @@ module.exports = function(config) {
|
|||
'bower_components/angular-mocks/angular-mocks.js',
|
||||
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js',
|
||||
'src/js/**/*.js',
|
||||
'test/helpers.js',
|
||||
'test/**/*.js'
|
||||
],
|
||||
|
||||
|
@ -47,6 +48,12 @@ module.exports = function(config) {
|
|||
'test/old/*'
|
||||
],
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
// reporter: 'html', // change Karma's debug.html to the mocha web reporter
|
||||
ui: 'tdd'
|
||||
}
|
||||
},
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
var incomplete2of2Wallet = {
|
||||
"network": "livenet",
|
||||
"xPrivKey": "xprv9s21ZrQH143K27bhzfejhNcitEAJgLKCfdLxwhr1FLu43FLqLwscAxXgmkucpF4k8eGmepSctkiQDbcR98Qd1bzSeDuR9jeyQAQEanPT2A4",
|
||||
"xPubKey": "xpub6CkPnrzSUp9qzBVM3hpo4oS2JKC6GJq6brE1yW59QrnhDpvkFLakpxUGRGXH62fiXb5S2VbnD4h2DLoCMfSkwfonbNgNYTJw9Ko5SqWEqCR",
|
||||
"requestPrivKey": "0cb89231b31dfaae9034ba794b9c48597eb573429f7b4b1f95e1945b22166bd5",
|
||||
"requestPubKey": "022941a5ecb8c7224f812ad6b03bd1c9bb77861080b21703eabe18ef9a72b48e72",
|
||||
"copayerId": "3d4eb9b439eee1b2b73cf792eda52e420f4665109c7234a50cf3cdbf296ea8fb",
|
||||
"publicKeyRing": [{
|
||||
"xPubKey": "xpub6CkPnrzSUp9qzBVM3hpo4oS2JKC6GJq6brE1yW59QrnhDpvkFLakpxUGRGXH62fiXb5S2VbnD4h2DLoCMfSkwfonbNgNYTJw9Ko5SqWEqCR",
|
||||
"requestPubKey": "022941a5ecb8c7224f812ad6b03bd1c9bb77861080b21703eabe18ef9a72b48e72"
|
||||
}],
|
||||
"walletId": "7bd8d22f-d132-43e1-b259-d5b430752553",
|
||||
"walletName": "A test wallet",
|
||||
"m": 2,
|
||||
"n": 2,
|
||||
"walletPrivKey": "Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy",
|
||||
"personalEncryptingKey": "1fgFP/uoLhVxJiMXOWQznA==",
|
||||
"sharedEncryptingKey": "FZIY4+p4TfBAKRclKtrROw==",
|
||||
"copayerName": "me",
|
||||
"mnemonic": "dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero",
|
||||
"entropySource": "79e60ad83e04ee40967147fd6ac58f986c7dcf6c82b125fb4e8c30ff9f9584ee",
|
||||
"mnemonicHasPassphrase": false,
|
||||
"derivationStrategy": "BIP44",
|
||||
"account": 0,
|
||||
"addressType": "P2SH"
|
||||
};
|
||||
var testnet1of1Wallet = {
|
||||
"network": "testnet",
|
||||
"xPrivKey": "tprv8ZgxMBicQKsPdK35ubrjCCpPCaBZA7QyKtxNNDWvYyjDAhtxV1HVNLzqwntAJ5QH1RTksRSfbuHLUYvMdGFmy9vHCb4yDRAR2zKqmX8mVa8",
|
||||
"xPubKey": "tpubDDN7B6QnxsbomkZfPFRj6CVtC7LVh6ufoTpvzHfutjiHbu4hmiEGYDzxo5mgfqkQkBuwZPFkTYLNmQeLg7eFvdb4SFH1LW35sQD6xfymmRP",
|
||||
"requestPrivKey": "aa39d4d780ad7ec36e26cbd0c0250bce85dfdd8aa7f2222ec7c86d6d62f242d7",
|
||||
"requestPubKey": "038bb7cc1238280e893dd6949bfce770a319892b3c9045112ec7810191d4157ced",
|
||||
"copayerId": "5c474b568bde8cd39efe069cd6aff2a80ab1cb18d3b9ae81f8225286f94856bc",
|
||||
"publicKeyRing": [{
|
||||
"xPubKey": "tpubDDN7B6QnxsbomkZfPFRj6CVtC7LVh6ufoTpvzHfutjiHbu4hmiEGYDzxo5mgfqkQkBuwZPFkTYLNmQeLg7eFvdb4SFH1LW35sQD6xfymmRP",
|
||||
"requestPubKey": "038bb7cc1238280e893dd6949bfce770a319892b3c9045112ec7810191d4157ced"
|
||||
}],
|
||||
"walletId": "66d3afc9-7d76-4b25-850e-aa62fcc53a7d",
|
||||
"walletName": "kk",
|
||||
"m": 1,
|
||||
"n": 1,
|
||||
"walletPrivKey": "1d6eb8e5a9f8944e97c2f13423c137ce912fac00f7eb5b3ffe6e3c161ea98bf7",
|
||||
"personalEncryptingKey": "A2dQiAwpFY2xwIhE26ClFQ==",
|
||||
"sharedEncryptingKey": "z0BtAIFclGQMH6eHqK9e3w==",
|
||||
"copayerName": "me",
|
||||
"mnemonic": "cheese where alarm job conduct donkey license pave congress pepper fence current",
|
||||
"entropySource": "5c84e65837c0fbd11db935953dbacb60f5c33f40ecfe95e0feded1f62a5ee15d",
|
||||
"mnemonicHasPassphrase": false,
|
||||
"derivationStrategy": "BIP44",
|
||||
"account": 0,
|
||||
"addressType": "P2PKH"
|
||||
};
|
||||
|
||||
var PROFILE = {
|
||||
incomplete2of2: {
|
||||
credentials: [incomplete2of2Wallet],
|
||||
createdOn: 1463519749,
|
||||
disclaimerAccepted: true,
|
||||
},
|
||||
testnet1of1: {
|
||||
credentials: [testnet1of1Wallet],
|
||||
createdOn: 1463519749,
|
||||
disclaimerAccepted: true,
|
||||
},
|
||||
};
|
|
@ -16,10 +16,8 @@ describe('walletService', function() {
|
|||
walletService = _walletService_;
|
||||
}));
|
||||
|
||||
describe('walletService', function() {
|
||||
it('should be defined', function() {
|
||||
should.exist(walletService);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue