temporary remove tests

This commit is contained in:
Matias Alejo Garcia 2016-10-14 16:41:35 -03:00
parent 79dbcf88d5
commit 84bc38e6b6
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
20 changed files with 0 additions and 4361 deletions

View File

@ -70,19 +70,8 @@
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"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",
"karma": "^0.13.22",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^1.0.1",
"karma-cli": "^1.0.0",
"karma-coverage": "^1.0.0",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.3",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon": "^1.0.5",
"load-grunt-tasks": "^3.5.0",
"mocha": "^2.4.5",
"phantomjs-prebuilt": "^2.1.7",

View File

@ -1,49 +0,0 @@
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) {
scope.initFlow();
should.exist(scope.mnemonicWords);
scope.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() {
scope.initFlow();
scope.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) {
scope.walletName.should.equal('kk');
done();
});
});
});

View File

@ -1,18 +0,0 @@
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);
});
});

View File

@ -1,185 +0,0 @@
describe('createController', function() {
var fixtures = {
// Store prefs
'1eda3e702196b8d5d82fae129249bc79f0d5be2f5309a4e39855e7eb4ad31428': {},
'31f5deeef4cf7fd8fc67297179232e8e4590532960454ad958009132fef3daae': {},
// createWallet 1-1
//
'b665ad8991c67f8f7e8ffb7e86c3b930fd3ff56c68eb6fd441bf374559cfe59c': {
"walletId": "63d910e8-3e1b-4aac-97e9-aa0299a74c2c"
},
'd5cc6adebc752c154998f1c96af2b24e21e52dbd7c07008c333af03b905ffb85': {
"copayerId": "a9dcee10fe9c611300e6c7926ece20780f89b9a98baaa342928038b5503ed929",
"wallet": {
"version": "1.0.0",
"createdOn": 1465385318,
"id": "63d910e8-3e1b-4aac-97e9-aa0299a74c2c",
"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,
"singleAddress": false,
"status": "complete",
"publicKeyRing": [{
"xPubKey": "xpub6DRjAgkh3vGTWDcEmDp4TPwy48Nu8yrp6swCEdCCLL615CgnZon7r3vXYr8LYibMLJh5DriGSito1FRBwVoBkjD1ZWG4dmgiC935wLj3nQC",
"requestPubKey": "02befcc7499abcecf9608bb05e665f374434a89ca0c4e9baeab7dd28c027143458"
}],
"copayers": [{
"version": 2,
"createdOn": 1465385318,
"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
'5a1d11ebc2a011f018b049de6b5c6b990cdc8e280644103f95a995321dbf0248': {
"walletId": "2f50f598-7550-4e54-8032-15aa892309fb"
},
// join
'58f2f3a6f11cd7dee9a75e026e3ba570c09b952bfea05f596fdb48e6ea323f21': {
"copayerId": "3d4eb9b439eee1b2b73cf792eda52e420f4665109c7234a50cf3cdbf296ea8fb",
"wallet": {
"version": "1.0.0",
"createdOn": 1465347188,
"id": "2f50f598-7550-4e54-8032-15aa892309fb",
"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,
"singleAddress": false,
"status": "pending",
"publicKeyRing": [],
"copayers": [{
"version": 2,
"createdOn": 1465347188,
"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.isSingleAddress = false;
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();
});
});
});

View File

@ -1,82 +0,0 @@
describe('disclaimerController', function() {
var walletService;
var storeProfile;
var fixtures = {
'e4d8ae25e03e5fef2e553615b088cfce222083828c13fdb37b8b6cf87bf76236': {
"walletId": "215f125d-57e7-414a-9723-448256113440",
},
'3f3b354d45c3eae3e4fe8830fcb728e5e570515af86e1a35deff0048a7a5e6b5': {
"copayerId": "1a91ead1b6d13da882a25377a20e460df557e77008ea4f60eecbf984f786cf03",
"wallet": {
"version": "1.0.0",
"createdOn": 1465347281,
"id": "215f125d-57e7-414a-9723-448256113440",
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"/gaG7FIkhCiwsWKZUR0sL/cxH+zHMK0=\"}",
"m": 1,
"n": 1,
"singleAddress": false,
"status": "complete",
"publicKeyRing": [{
"xPubKey": "xpub6Cb7MYAX7mJR28MfFueCsoDVVHhoWkQxRC4viAeHanYwRNgDo5xMF42xmAeExzfyPXX3GaALNA8hWFMekVYvDF2BALommUhMgZ52szh88fd",
"requestPubKey": "029a167eebe3ccd9987d41743477f8b75e1f3c30463187e1b106e0cc1155efa4dd"
}],
"copayers": [{
"version": 2,
"createdOn": 1465347281,
"xPubKey": "xpub6Cb7MYAX7mJR28MfFueCsoDVVHhoWkQxRC4viAeHanYwRNgDo5xMF42xmAeExzfyPXX3GaALNA8hWFMekVYvDF2BALommUhMgZ52szh88fd",
"id": "1a91ead1b6d13da882a25377a20e460df557e77008ea4f60eecbf984f786cf03",
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"wwZd+2LQgYR6cA==\"}",
"requestPubKey": "029a167eebe3ccd9987d41743477f8b75e1f3c30463187e1b106e0cc1155efa4dd",
"signature": "3045022100ac3f31ef145eabde6a125958aa9d63c2bd4aa27717d7f6905c3e3ff1e733ee8e02206a43200b775ee5c8f7a85c4d3309d155240d5de46a7d9c5e60045bf49779f40b",
"requestPubKeys": [{
"key": "029a167eebe3ccd9987d41743477f8b75e1f3c30463187e1b106e0cc1155efa4dd",
"signature": "3045022100ac3f31ef145eabde6a125958aa9d63c2bd4aa27717d7f6905c3e3ff1e733ee8e02206a43200b775ee5c8f7a85c4d3309d155240d5de46a7d9c5e60045bf49779f40b"
}],
"customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"9l63hoVnA71LshCC5xbOTHA+ivBzux7u8SAci56p4aaVIF4qzXQhQKFX+sAFGfBjULm/E1st6awdXnxbAgjbF7D0zsbBFLFOSCw+ko5Xc6o=\"}"
}],
"pubKey": "026d95bb5cc2a30c19e22379ae78b4757aaa2dd0ccbd15a1db054fb50cb98ed361",
"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,
noProfile: true,
}, done);
});
afterEach(function(done) {
mocks.clear({}, done);
});
it('should be defined', function() {
should.exist(ctrl);
});
it('should create the initial profile', function(done) {
localStorage.clear();
ctrl.init({
walletPrivKey: 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy',
mnemonic: 'tunnel fork scare industry noble snow tank bullet over gesture nuclear next',
});
setTimeout(function() {
mocks.ongoingProcess.set.getCall(1).args[0].should.equal('creatingWallet');
mocks.ongoingProcess.set.getCall(1).args[1].should.equal(false);
done();
}, 100);
});
});

View File

@ -1,112 +0,0 @@
describe('importController', function() {
var walletService;
var storeProfile;
var fixtures = {
'31f5deeef4cf7fd8fc67297179232e8e4590532960454ad958009132fef3daae': {},
'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';
scope.setSeedSource();
scope.importMnemonic(fakeForm);
should.not.exist(scope.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();
});
});
});

View File

@ -1,71 +0,0 @@
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.skip('should updates remote preferences', function(done) {
ctrl.updateRemotePreferences({}, function() {
done();
});
});
});
});

View File

@ -1,150 +0,0 @@
describe('joinController', function() {
var walletService;
var fixtures = {
// join
'668623e51aaae25c637fb9c57bb30a169a0ff67fa1e67e6e61643c7e5e580a66': {
"copayerId": "962fb5dd31d9f715efdbb33d41533d272bb6c2ecd28bbb8181358f86b08253dd",
"wallet": {
"version": "1.0.0",
"createdOn": 1466006460,
"id": "10387ed3-51cf-43b4-91fe-ad85ca2ae368",
"name": "{\"iv\":\"4Agx234j4p+TQS0QXj7bow==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"IEohefHXl/tr4rA=\"}",
"m": 2,
"n": 2,
"singleAddress": false,
"status": "complete",
"publicKeyRing": [{
"xPubKey": "xpub6C6dynsH56i7VhzHzo2ZcJguHsjYuUuoPcAdku8h6c7ZaJSYb4WQjKcGdggbpWEuaQspY3LHmFUoCQhk1ErmdegXnsJeSxoKqiPD1CUxVvT",
"requestPubKey": "0200fbedb7d04af9edbd1602103c1ff68454fd009fd8b1acd957441e776c69ff59"
}, {
"xPubKey": "xpub6BsR71KDdSPMePtuipRiWKMC2Q9XEXfk6WM1trbJzPEhcwVBKyN9UhWtpnGv2pu4mtZyKFRgwL98hDH6TBdeEFNVp8Jf81kPBKPeWpn4sWr",
"requestPubKey": "02ad777ba00bf085a2d167c0600df290037d40e5e0d33b5f8e345b0b80a8861bd4"
}],
"copayers": [{
"version": 2,
"createdOn": 1466006460,
"id": "4f72d7bc290a0343a5096cf28999d5d329a9be42651b061fb9489130d0cf9af9",
"name": "{\"iv\":\"RZr7/0eA7F70T/wBCJo7kw==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"nL4c40ADLWELtoE=\"}",
"xPubKey": "xpub6C6dynsH56i7VhzHzo2ZcJguHsjYuUuoPcAdku8h6c7ZaJSYb4WQjKcGdggbpWEuaQspY3LHmFUoCQhk1ErmdegXnsJeSxoKqiPD1CUxVvT",
"requestPubKey": "0200fbedb7d04af9edbd1602103c1ff68454fd009fd8b1acd957441e776c69ff59",
"signature": "304402200af094bbb7c432c9a1323534db125431c87bdec9678f40e89a42f209115a222202207a87a27b5f14bf931e1a15d71aa8407118398e5540a8fcbaf7caffef534b6a49",
"requestPubKeys": [{
"key": "0200fbedb7d04af9edbd1602103c1ff68454fd009fd8b1acd957441e776c69ff59",
"signature": "304402200af094bbb7c432c9a1323534db125431c87bdec9678f40e89a42f209115a222202207a87a27b5f14bf931e1a15d71aa8407118398e5540a8fcbaf7caffef534b6a49"
}],
"customData": "{\"iv\":\"kSIFrEhNScxUNG5BMnV34A==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"strUeMXiPhTPmsatrStRfaF9+ZD1LU+m+I6Xeu4m0s43DIqc/DYJwm+37fatohNKQ6J7FQKTCJUgMiidAe30K6Dw7J7GA6mFhedMsGLJNbOmBEhRN0AAbwXW6B0=\"}"
}, {
"version": 2,
"createdOn": 1466006511,
"xPubKey": "xpub6BsR71KDdSPMePtuipRiWKMC2Q9XEXfk6WM1trbJzPEhcwVBKyN9UhWtpnGv2pu4mtZyKFRgwL98hDH6TBdeEFNVp8Jf81kPBKPeWpn4sWr",
"id": "962fb5dd31d9f715efdbb33d41533d272bb6c2ecd28bbb8181358f86b08253dd",
"name": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"UKYkKqeia8gWrLqaJ+TuzA/LVlrG\"}",
"requestPubKey": "02ad777ba00bf085a2d167c0600df290037d40e5e0d33b5f8e345b0b80a8861bd4",
"signature": "3045022100f7c7bbc49ce679e67420db8614bf59dfbd798e8ad95a0427305ae5008e0aa41b02203997647b80cc6e5a365048dc5b7b1822809b3c9209a053aaeef7e9f3920d7cef",
"requestPubKeys": [{
"key": "02ad777ba00bf085a2d167c0600df290037d40e5e0d33b5f8e345b0b80a8861bd4",
"signature": "3045022100f7c7bbc49ce679e67420db8614bf59dfbd798e8ad95a0427305ae5008e0aa41b02203997647b80cc6e5a365048dc5b7b1822809b3c9209a053aaeef7e9f3920d7cef"
}],
"customData": "{\"iv\":\"BZQVWAP6d1e4G8Fq1rQKbA==\",\"v\":1,\"iter\":1,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"ct\":\"HTlgRDT46ysMT3+XzhxeXgrOfJ1Fq+kiTWG/q7RqISdWWE+cmP5LcI6+PSysEpo66AjOlI9ofyMVxKtptabWYSNgydrhnqZ5EKY0TnFRq8Ov7a8+btXf9n9BDsM=\"}"
}],
"pubKey": "03bdebf86549b272addd61076e026d2f6a225db514f08b8fad08536a8c4a6792c1",
"network": "livenet",
"derivationStrategy": "BIP44",
"addressType": "P2SH",
"addressManager": {
"version": 2,
"derivationStrategy": "BIP44",
"receiveAddressIndex": 0,
"changeAddressIndex": 0,
"copayerIndex": 2147483647
},
"scanStatus": null
}
},
'197031879d401f75c308e3d5014ac2e9560ec805e1fdd58c778e0ae0bfe7ec0a': {},
}
beforeEach(function(done) {
mocks.init(fixtures, 'joinController', {}, done);
})
afterEach(function(done) {
mocks.clear({}, done);
});
it('should be defined', function() {
should.exist(ctrl);
});
// // 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('should join a wallet once the form is submitted', function(done) {
// View' s joinForm is not available
//join.onQrCodeScanned('aQRCode');
//
scope.seedSource = {
id: 'set'
};
ctrl.setSeedSource();
// FROM DATA
scope._walletPrivKey = 'Kz4CFSTgLzoYfMkt97BTBotUbZYXjMts6Ej9HbVfCf5oLmun1BXy';
var fakeForm = {
secret: {
$modelValue: '31B6DG8f12vGhG7hWhQy2PKwngiNnQ4ijPcePSwanQ2gD6N4mWs3eVPtdwZqRQbHnLQyxhoJksL'
},
myName: {
$modelValue: 'myCopayerName'
},
bwsurl: 'null',
createPassphrase: {
$modelValue: null
},
privateKey: {
$modelValue: 'useful poet rely letter cause fat student tumble animal toddler proof husband',
},
passphrase: {
$modelValue: null,
},
};
ctrl.join(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('xprv9s21ZrQH143K3ettHXncETrbUjzrTB7yBfhzjnYjbFgExeNMecTGPvJgje2WQeSFS17Sd8ssz8FQuCbm4rK62ojAwPCX8GHtjHNHsmJsbUa');
// m/44'/0'/0'
c.xPubKey.should.equal('xpub6BsR71KDdSPMePtuipRiWKMC2Q9XEXfk6WM1trbJzPEhcwVBKyN9UhWtpnGv2pu4mtZyKFRgwL98hDH6TBdeEFNVp8Jf81kPBKPeWpn4sWr');
c.walletName.should.equal('2-2');
done();
});
});
});

View File

@ -1,37 +0,0 @@
describe('Preferences History Controller', function() {
var walletService;
var txHistory = '[{"txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","action":"received","amount":120000,"fees":4862,"time":1464969291,"confirmations":8,"outputs":[{"amount":120000,"address":"2N4HgtF9cJSzxhVkj5gbKxwJSKWBmnb9FNJ","message":null}],"note":{"body":"just a comment","editedBy":"31a8c3c0be9ffbb9f257c95f3fd2f73a59cf81e40199ba5918417270db8c4cdb","editedByName":"2-2","editedOn":1464969101},"message":null,"creatorName":"","hasUnconfirmedInputs":false,"amountStr":"1,200 bits","alternativeAmountStr":"0.68 USD","feeStr":"49 bits","safeConfirmed":"6+"}]';
describe('Complete 1-1 wallet', function() {
beforeEach(function(done) {
mocks.init(FIXTURES, 'preferencesHistory', {
loadProfile: PROFILE.testnet1of1,
loadStorage: {
'txsHistory-66d3afc9-7d76-4b25-850e-aa62fcc53a7d': txHistory,
},
}, done);
});
afterEach(function(done) {
mocks.clear({}, done);
});
it('should be defined', function() {
should.exist(ctrl);
});
it('should export csv', function(done) {
scope.csvHistory(function(err) {
should.not.exist(err);
should.exist(scope.csvReady);
scope.csvReady.should.equal(true);
should.exist(scope.csvContent);
JSON.stringify(scope.csvContent).should.equal('[{"Date":"2016-06-03T15:54:51.000Z","Destination":"","Description":"","Amount":"0.00120000","Currency":"BTC","Txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","Creator":"","Copayers":"","Comment":"just a comment"}]');
done();
});
});
});
});

View File

@ -1,19 +0,0 @@
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

View File

@ -1,262 +0,0 @@
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.ongoingProcess = {
set: sinon.stub(),
clear: sinon.stub(),
};
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('ionic');
module('ngLodash');
module('angularMoment');
module('gettext');
module('stateMock');
module('bwcModule', function($provide) {
console.log(' * bwcService decorator');
$provide.decorator('bwcService', function($delegate, lodash) {
var getClient = $delegate.getClient;
// Fix Encryption IVs
var utils = $delegate.getUtils();
utils.SJCL.iv = 'BZQVWAP6d1e4G8Fq1rQKbA==';
$delegate.getClient = function(walletData, opts) {
var bwc = new $delegate.Client();
if (walletData)
bwc.import(walletData, {
baseUrl: opts.bwsurl || 'https://bws.bitpay.com/bws/api',
verbose: opts.verbose,
transports: ['polling'],
});
function createHash(method, url, args) {
var headers = JSON.stringify(bwc._getHeaders(method, url, args));
// Fixes BWC version... TODO
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));
};
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('copayApp.services', {
$modal: mocks.modal,
$timeout: mocks.$timeout,
$state: mocks.$state,
});
module('copayApp.controllers');
inject(function($rootScope, $controller, $injector, lodash, _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
});
$httpBackend.whenGET(/views.*/).respond(200, '');
_configService_.get(function() {
function startController() {
console.log(' * starting Controller:', controllerName);
ctrl = $controller(controllerName, {
$scope: scope,
$modal: mocks.modal,
ongoingProcess: mocks.ongoingProcess,
notification: mocks.notification,
configService: _configService_,
profileService: _profileService_,
go: mocks.go,
$document: mocks.$document,
});
};
if (opts.initController)
startController();
if (opts.loadStorage) {
lodash.each(opts.loadStorage, function(v, k) {
localStorage.setItem(k, v);
});
}
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 {
if (opts.noProfile){
return done();
}
_profileService_.create({
noWallet: true
}, function(err) {
should.not.exist(err, err);
if (opts.noDisclaimer){
return done();
}
_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();
};

View File

@ -1,115 +0,0 @@
// Karma configuration
// Generated on Thu Mar 12 2015 18:13:33 GMT-0300 (ART)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '..',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon'],
// list of files / patterns to load in the browser
files: [
'bower_components/qrcode-generator/js/qrcode.js',
'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js',
'bower_components/moment/min/moment-with-locales.js',
'bower_components/ionic/release/js/ionic.bundle.js',
'bower_components/angular-moment/angular-moment.js',
'bower_components/ng-lodash/build/ng-lodash.js',
'bower_components/angular-qrcode/angular-qrcode.js',
'bower_components/angular-gettext/dist/angular-gettext.js',
'bower_components/ng-csv/build/ng-csv.js',
'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js',
'bower_components/angular-clipboard/angular-clipboard.js',
'bower_components/angular-mocks/angular-mocks.js',
'angular-pbkdf2/angular-pbkdf2.js',
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js',
'src/js/**/*.js',
'test/helpers.js',
'test/**/*.js'
],
// list of files to exclude
exclude: [
'src/js/translations.js',
// 'src/js/version.js',
'test/karma.conf.js',
'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
preprocessors: {
'src/js/**/*.js': ['coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha', 'coverage'],
// optionally, configure the reporter
coverageReporter: {
dir: 'coverage/',
reporters: [{
type: 'html',
subdir: 'report-html'
}, {
type: 'lcov',
subdir: 'report-lcov'
}, {
type: 'text-summary'
}]
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
plugins: [
'karma-mocha-reporter',
'karma-coverage',
'karma-mocha',
'karma-chai',
'karma-sinon',
'karma-phantomjs-launcher',
'karma-chrome-launcher',
],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};

File diff suppressed because it is too large Load Diff

View File

@ -1,250 +0,0 @@
'use strict';
//
// test/unit/directives/directivesSpec.js
//
describe("Unit: Testing Directives", function() {
var $scope, form;
beforeEach(module('copayApp.directives'));
beforeEach(inject(function($rootScope) {
var w = {};
w.isComplete = sinon.stub().returns(true);
w.privateKey = {};
w.settings = {
unitToSatoshi: 100,
unitDecimals: 2,
alternativeName: 'US Dollar',
alternativeIsoCode: 'USD',
};
w.addressBook = {
'juan': '1',
};
w.totalCopayers = 2;
w.getMyCopayerNickname = sinon.stub().returns('nickname');
w.getMyCopayerId = sinon.stub().returns('id');
w.privateKey.toObj = sinon.stub().returns({
wallet: 'mock'
});
w.getSecret = sinon.stub().returns('secret');
w.getName = sinon.stub().returns('fakeWallet');
w.exportEncrypted = sinon.stub().returns('1234567');
w.getTransactionHistory = sinon.stub().yields({});
w.getNetworkName = sinon.stub().returns('testnet');
w.createTx = sinon.stub().yields(null);
w.sendTx = sinon.stub().yields(null);
w.requiresMultipleSignatures = sinon.stub().returns(true);
w.getTxProposals = sinon.stub().returns([1,2,3]);
$rootScope.wallet = w;
}));
describe('Validate Address', function() {
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
var element = angular.element(
'<form name="form">' +
'<input type="text" id="address" name="address" placeholder="Send to" ng-model="address" valid-address required>' +
'</form>'
);
$scope.model = {
address: null
};
$compile(element)($scope);
$scope.$digest();
form = $scope.form;
}));
it('should validate with network', inject(function($rootScope) {
$rootScope.wallet.getNetworkName = sinon.stub().returns('testnet');
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
expect(form.address.$invalid).to.equal(false);
}));
it('should not validate with other network', inject(function($rootScope) {
$rootScope.wallet.getNetworkName = sinon.stub().returns('livenet');
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
expect(form.address.$invalid).to.equal(true);
}));
it('should not validate random', function() {
form.address.$setViewValue('thisisaninvalidaddress');
expect(form.address.$invalid).to.equal(true);
});
});
describe('Validate Amount', function() {
describe('Unit: bits', function() {
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
var element = angular.element(
'<form name="form">' +
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.00000001" max="10000000000" valid-amount required>' +
'</form>'
);
$scope.model = {
amount: null
};
$compile(element)($scope);
$scope.$digest();
form = $scope.form;
}));
it('should validate', function() {
form.amount.$setViewValue(100);
expect(form.amount.$invalid).to.equal(false);
form.amount.$setViewValue(800);
expect(form.amount.$invalid).to.equal(false);
form.amount.$setViewValue(900);
});
it('should not validate', function() {
form.amount.$setViewValue(0);
expect(form.amount.$invalid).to.equal(true);
form.amount.$setViewValue(999999999999);
expect(form.amount.$invalid).to.equal(true);
});
});
describe('Unit: BTC', function() {
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100000000;
w.settings.unitName = 'BTC';
w.settings.unitDecimals = 8;
$rootScope.availableBalance = 0.04;
var element = angular.element(
'<form name="form">' +
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.00000001" max="10000000000" valid-amount required>' +
'</form>'
);
$scope.model = {
amount: null
};
$compile(element)($scope);
$scope.$digest();
form = $scope.form;
}));
it('should validate', function() {
form.amount.$setViewValue(0.01);
expect(form.amount.$invalid).to.equal(false);
form.amount.$setViewValue(0.039);
expect(form.amount.$invalid).to.equal(false);
form.amount.$setViewValue(100292.039);
expect(form.amount.$invalid).to.equal(false);
});
it('should not validate', function() {
form.amount.$setViewValue(0.039998888888888);
expect(form.amount.$invalid).to.equal(true);
form.amount.$setViewValue(0);
expect(form.amount.$invalid).to.equal(true);
form.amount.$setViewValue(0.0);
expect(form.amount.$invalid).to.equal(true);
});
});
});
describe('Contact directive', function() {
var element1, element2;
beforeEach(inject(function($compile, $rootScope) {
$rootScope.wallet = {
addressBook: {
'2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT': {
label: ':)'
}
}
}
element1 = angular.element(
'<contact address="2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT" />'
);
element2 = angular.element(
'<contact address="2MvCKdnwEMiaexi247gi738U6pwUFZxbhXn" />'
);
$compile(element1)($rootScope);
$compile(element2)($rootScope);
$rootScope.$digest();
}));
it('should replace the content', function() {
expect(element1.html()).to.equal(':)');
expect(element2.html()).to.equal('2MvCKdnwEMiaexi247gi738U6pwUFZxbhXn');
});
});
describe('Password strength', function() {
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
var element = angular.element(
'<input type="password" name="password" ng-model="password" check-strength="passwordStrength" value="asd" required>'
);
$compile(element)($scope);
$scope.$digest();
}));
it('should check very weak password', function() {
$scope.password = 'asd';
$scope.$digest();
expect($scope.passwordStrength.strength).to.equal(1);
});
it('should check weak password', function() {
$scope.password = 'asdasdASDASD';
$scope.$digest();
expect($scope.passwordStrength.message).to.equal('Weak, add numerals');
});
it('should check medium password', function() {
$scope.password = 'asdasdA1';
$scope.$digest();
expect($scope.passwordStrength.message).to.equal('Medium, add punctuation');
});
it('should check strong password', function() {
$scope.password = 'asdasdASDASD1{';
$scope.$digest();
expect($scope.passwordStrength.message).to.equal('Strong, add punctuation');
});
});
describe('Match Password Inputs', function() {
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
$rootScope.availableBalance = 1000;
var element = angular.element(
'<form name="form">' +
'<input type="password" ng-model="walletPassword" name="walletPassword" required>' +
'<input type="password" ng-model="walletPasswordConfirm" name="walletPasswordConfirm" match="walletPassword" required>' +
'</form>'
);
$scope.model = {
walletPassword: null,
walletPasswordConfirm: null
};
$compile(element)($scope);
$scope.$digest();
form = $scope.form;
}));
it('should not validate', function() {
form.walletPassword.$setViewValue('mysecretpassword');
form.walletPasswordConfirm.$setViewValue('mySecretPassword');
$scope.$digest();
expect(form.walletPasswordConfirm.$invalid).to.equal(true);
});
it('should validate', function() {
form.walletPassword.$setViewValue('mysecretpassword123');
form.walletPasswordConfirm.$setViewValue('mysecretpassword123');
$scope.$digest();
expect(form.walletPasswordConfirm.$invalid).to.equal(false);
});
});
});

View File

@ -1,168 +0,0 @@
'use strict';
//
// test/unit/filters/filtersSpec.js
//
describe('Angular Filters', function() {
beforeEach(angular.mock.module('copayApp'));
beforeEach(module('copayApp.filters'));
beforeEach(inject(function($rootScope) {
var w = {};
w.isComplete = sinon.stub().returns(true);
w.privateKey = {};
w.settings = {
unitToSatoshi: 100,
unitDecimals: 2,
alternativeName: 'US Dollar',
alternativeIsoCode: 'USD',
};
w.addressBook = {
'juan': '1',
};
w.balanceByAddr = [{
'address1': 1
}];
w.totalCopayers = 2;
w.getMyCopayerNickname = sinon.stub().returns('nickname');
w.getMyCopayerId = sinon.stub().returns('id');
w.privateKey.toObj = sinon.stub().returns({
wallet: 'mock'
});
w.getSecret = sinon.stub().returns('secret');
w.getName = sinon.stub().returns('fakeWallet');
w.getId = sinon.stub().returns('id');
w.exportEncrypted = sinon.stub().returns('1234567');
w.getTransactionHistory = sinon.stub().yields({});
w.getNetworkName = sinon.stub().returns('testnet');
w.getAddressesInfo = sinon.stub().returns({});
w.createTx = sinon.stub().yields(null);
w.sendTx = sinon.stub().yields(null);
w.requiresMultipleSignatures = sinon.stub().returns(true);
w.getTxProposals = sinon.stub().returns([1, 2, 3]);
$rootScope.wallet = w;
}));
var walletConfig = {
requiredCopayers: 3,
totalCopayers: 5,
spendUnconfirmed: 1,
reconnectDelay: 100,
networkName: 'testnet',
alternativeName: 'lol currency',
alternativeIsoCode: 'LOL'
};
describe('removeEmpty addresses', function() {
it('should work with empty lists', inject(function($filter) {
var removeEmpty = $filter('removeEmpty');
expect(removeEmpty([]).length).to.equal(0);
}));
it('should work with undefined', inject(function($filter) {
var removeEmpty = $filter('removeEmpty');
expect(removeEmpty(undefined).length).to.equal(0);
}));
it('should filter empty change addresses from other copayers', inject(function($filter) {
var removeEmpty = $filter('removeEmpty');
var addresses = [{
owned: true,
isChange: false,
balance: 0
}, {
owned: false,
isChange: false,
balance: 0
}, {
owned: true,
isChange: true,
balance: 0
}, {
owned: false,
isChange: true,
balance: 0
}];
expect(removeEmpty(addresses).length).to.equal(2);
}));
});
describe('noFractionNumber', function() {
describe('noFractionNumber bits', function() {
beforeEach(inject(function($rootScope) {
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100;
w.settings.unitName = 'bits';
}));
it('should format number to display correctly', inject(function($filter) {
var noFraction = $filter('noFractionNumber');
expect(noFraction(3100)).to.equal('3,100');
expect(noFraction(3100200)).to.equal('3,100,200');
expect(noFraction(3)).to.equal('3');
expect(noFraction(0.3)).to.equal(0.3);
expect(noFraction(0.30000000)).to.equal(0.3);
expect(noFraction(3200.01)).to.equal('3,200.01');
expect(noFraction(3200890.010000)).to.equal('3,200,890.01');
}));
});
describe('noFractionNumber BTC', function() {
beforeEach(inject(function($rootScope) {
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100000000;
w.settings.unitName = 'BTC';
}));
it('should format number to display correctly', inject(function($filter) {
var noFraction = $filter('noFractionNumber');
expect(noFraction(0.30000000)).to.equal(0.3);
expect(noFraction(0.00302000)).to.equal(0.00302);
expect(noFraction(1.00000001)).to.equal(1.00000001);
expect(noFraction(3.10000012)).to.equal(3.10000012);
expect(noFraction(0.00100000)).to.equal(0.001);
expect(noFraction(0.00100009)).to.equal(0.00100009);
expect(noFraction(2000.00312011)).to.equal('2,000.00312011');
expect(noFraction(2000998.00312011)).to.equal('2,000,998.00312011');
}));
});
describe('noFractionNumber mBTC', function() {
beforeEach(inject(function($rootScope) {
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100000;
w.settings.unitName = 'mBTC';
}));
it('should format number to display correctly', inject(function($filter) {
var noFraction = $filter('noFractionNumber');
expect(noFraction(0.30000)).to.equal(0.3);
expect(noFraction(0.00302)).to.equal(0.00302);
expect(noFraction(1.00001)).to.equal(1.00001);
expect(noFraction(3.10002)).to.equal(3.10002);
expect(noFraction(0.00100000)).to.equal(0.001);
expect(noFraction(0.00100009)).to.equal(0.001);
expect(noFraction(2000.00312)).to.equal('2,000.00312');
expect(noFraction(2000998.00312)).to.equal('2,000,998.00312');
}));
});
describe('noFractionNumber:custom fractionSize', function() {
it('should format number to display correctly', inject(function($filter) {
var noFraction = $filter('noFractionNumber');
expect(noFraction(0.30000, 0)).to.equal('0');
expect(noFraction(1.00001, 0)).to.equal('1');
expect(noFraction(3.10002, 0)).to.equal('3');
expect(noFraction(2000.00312, 0)).to.equal('2,000');
expect(noFraction(2000998.00312, 0)).to.equal('2,000,998');
}));
});
});
});

View File

@ -1,215 +0,0 @@
//
// test/unit/services/servicesSpec.js
//
//
//
var sinon = require('sinon');
var preconditions = require('preconditions').singleton();
describe("Angular services", function() {
beforeEach(angular.mock.module('copayApp'));
beforeEach(angular.mock.module('copayApp.services'));
beforeEach(module(function($provide) {
$provide.value('request', {
'get': function(_, cb) {
cb(null, null, [{
name: 'USD Dollars',
code: 'USD',
rate: 2
}]);
}
});
}));
beforeEach(inject(function($rootScope) {
var w = {};
w.isComplete = sinon.stub().returns(true);
w.privateKey = {};
w.settings = {
unitToSatoshi: 100,
unitDecimals: 2,
alternativeName: 'US Dollar',
alternativeIsoCode: 'USD',
};
w.addressBook = {
'juan': '1',
};
w.balanceByAddr = [{
'address1': 1
}];
w.totalCopayers = 2;
w.getMyCopayerNickname = sinon.stub().returns('nickname');
w.getMyCopayerId = sinon.stub().returns('id');
w.privateKey.toObj = sinon.stub().returns({
wallet: 'mock'
});
w.getSecret = sinon.stub().returns('secret');
w.getName = sinon.stub().returns('fakeWallet');
w.getId = sinon.stub().returns('id');
w.exportEncrypted = sinon.stub().returns('1234567');
w.getTransactionHistory = sinon.stub().yields({});
w.getNetworkName = sinon.stub().returns('testnet');
w.getAddressesInfo = sinon.stub().returns({});
w.createTx = sinon.stub().yields(null);
w.sendTx = sinon.stub().yields(null);
w.requiresMultipleSignatures = sinon.stub().returns(true);
w.getTxProposals = sinon.stub().returns([1, 2, 3]);
$rootScope.wallet = w;
}));
describe("Unit: balanceService", function() {
it('should updateBalance in bits', inject(function(balanceService, $rootScope) {
var w = $rootScope.wallet;
expect(balanceService.update).not.to.equal(null);
var Waddr = Object.keys($rootScope.wallet.balanceByAddr)[0];
var a = {};
a[Waddr] = 200;
w.getBalance = sinon.stub().yields(null, 100000001, a, 90000002, 5);
//retuns values in DEFAULT UNIT(bits)
balanceService.update(w, function() {
var b = w.balanceInfo;
expect(b.totalBalanceBTC).to.be.equal(1.00000001);
expect(b.availableBalanceBTC).to.be.equal(0.90000002);
expect(b.lockedBalanceBTC).to.be.equal(0.09999999);
expect(b.totalBalance).to.be.equal('1,000,000.01');
expect(b.availableBalance).to.be.equal('900,000.02');
expect(b.lockedBalance).to.be.equal('99,999.99');
expect(b.balanceByAddr[Waddr]).to.equal(2);
expect(b.safeUnspentCount).to.equal(5);
expect(b.topAmount).to.equal(899800.02);
}, false);
}));
});
describe("Unit: Notification Service", function() {
it('should contain a notification service', inject(function(notification) {
expect(notification).not.to.equal(null);
}));
});
describe("Unit: identityService Service", function() {
it('should contain a identityService service', inject(function(identityService) {
expect(identityService).not.to.equal(null);
}));
});
describe("Unit: pinService", function() {
it('should contain a pinService service', inject(function(pinService) {
expect(pinService).not.to.equal(null);
}));
it('should be able to check -> save -> get -> clear -> check', function(done) {
inject(function(pinService) {
pinService.save('123', 'user', 'pass', function(err) {
pinService.check(function(err, value) {
should.not.exist(err);
value.should.equal(true);
pinService.get('123', function(err, data) {
should.not.exist(err);
data.email.should.be.equal('user');
data.password.should.be.equal('pass');
pinService.clear(function(err) {
should.not.exist(err);
pinService.check(function(err, value) {
should.not.exist(err);
value.should.equal(false);
done();
});
});
});
});
})
})
});
});
describe("Unit: localstorageService", function() {
it('should contain a localstorageService service', inject(function(localstorageService) {
expect(localstorageService).not.to.equal(null);
}));
});
describe("Unit: Backup Service", function() {
it('should contain a backup service', inject(function(backupService) {
expect(backupService).not.to.equal(null);
}));
it('should backup in file', inject(function(backupService) {
var mock = sinon.mock(window);
var expectation = mock.expects('saveAs');
backupService._download({}, 'test');
expectation.once();
}));
});
describe("Unit: isMobile Service", function() {
it('should contain a isMobile service', inject(function(isMobile) {
expect(isMobile).not.to.equal(null);
}));
it('should not detect mobile by default', inject(function(isMobile) {
isMobile.any().should.equal(false);
}));
it('should detect mobile if user agent is Android', inject(function(isMobile) {
navigator.__defineGetter__('userAgent', function() {
return 'Android 2.2.3';
});
isMobile.any().should.equal(true);
}));
});
describe("Unit: uriHandler service", function() {
it('should contain a uriHandler service', inject(function(uriHandler) {
should.exist(uriHandler);
}));
it('should register', inject(function(uriHandler) {
(function() {
uriHandler.register();
}).should.not.throw();
}));
});
describe('Unit: Rate Service', function() {
it('should be injected correctly', inject(function(rateService) {
should.exist(rateService);
}));
it('should be possible to ask if it is available',
inject(function(rateService) {
should.exist(rateService.isAvailable);
})
);
it('should be possible to ask for conversion from fiat',
function(done) {
inject(function(rateService) {
rateService.whenAvailable(function() {
(1e8).should.equal(rateService.fromFiat(2, 'USD'));
done();
});
})
}
);
it('should be possible to ask for conversion to fiat',
function(done) {
inject(function(rateService) {
rateService.whenAvailable(function() {
(2).should.equal(rateService.toFiat(1e8, 'USD'));
done();
});
})
}
);
});
});

View File

@ -1,11 +0,0 @@
// 'use strict';
//
// describe('sidebarController', function(){
// var scope, controller;
//
// beforeEach(angular.mock.module('copayApp.controllers'));
//
// it('dummy test', function(){
// should.exist(true);
// });
// });

View File

@ -1,65 +0,0 @@
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,
},
};

View File

@ -1,24 +0,0 @@
describe('walletService', function() {
var walletService;
// Adds walletService's module dependencies
beforeEach(function() {
module('ngLodash');
module('gettext');
module('angularMoment');
module('bwcModule');
module('copayApp.services');
});
beforeEach(inject(function(_walletService_) {
walletService = _walletService_;
}));
it('should be defined', function() {
should.exist(walletService);
});
});