mirror of https://github.com/BTCPrivate/copay.git
fix tests
This commit is contained in:
parent
90ebd8deb5
commit
a30b8d81bb
|
@ -29,8 +29,7 @@ angular.module('copayApp.directives')
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function(scope, element, attrs, ctrl) {
|
link: function(scope, element, attrs, ctrl) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {});
|
||||||
});
|
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -697,8 +697,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
var amountSat = bignum(amountSatStr);
|
var amountSat = bignum(amountSatStr);
|
||||||
preconditions.checkArgument(new Address(toAddress).network().name === this.networkName);
|
preconditions.checkArgument(new Address(toAddress).network().name === this.getNetworkName());
|
||||||
|
|
||||||
if (!pkr.isComplete()) {
|
if (!pkr.isComplete()) {
|
||||||
throw new Error('publicKeyRing is not complete');
|
throw new Error('publicKeyRing is not complete');
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,24 @@ describe('Wallet model', function() {
|
||||||
return w;
|
return w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
it('#create, fail for network', function() {
|
||||||
|
|
||||||
|
var w = cachedCreateW2();
|
||||||
|
|
||||||
|
unspentTest[0].address = w.publicKeyRing.getAddress(1, true).toString();
|
||||||
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
||||||
|
|
||||||
|
var f = function() {
|
||||||
|
var ntxid = w.createTxSync(
|
||||||
|
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
||||||
|
'123456789',
|
||||||
|
null,
|
||||||
|
unspentTest
|
||||||
|
);
|
||||||
|
};
|
||||||
|
f.should.throw(Error);
|
||||||
|
});
|
||||||
|
|
||||||
it('#create, 1 sign', function() {
|
it('#create, 1 sign', function() {
|
||||||
|
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
|
@ -180,7 +198,7 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
||||||
|
|
||||||
var ntxid = w.createTxSync(
|
var ntxid = w.createTxSync(
|
||||||
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
unspentTest
|
unspentTest
|
||||||
|
@ -205,7 +223,7 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
||||||
|
|
||||||
var ntxid = w.createTxSync(
|
var ntxid = w.createTxSync(
|
||||||
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
comment,
|
comment,
|
||||||
unspentTest
|
unspentTest
|
||||||
|
@ -228,7 +246,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
var badCreate = function() {
|
var badCreate = function() {
|
||||||
w.createTxSync(
|
w.createTxSync(
|
||||||
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
comment,
|
comment,
|
||||||
unspentTest
|
unspentTest
|
||||||
|
@ -262,7 +280,7 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(index, isChange).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(index, isChange).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(index, isChange);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(index, isChange);
|
||||||
w.createTxSync(
|
w.createTxSync(
|
||||||
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
unspentTest
|
unspentTest
|
||||||
|
|
|
@ -174,12 +174,17 @@ describe("Unit: Controllers", function() {
|
||||||
expect(scope.showAddressBook()).equal(true);
|
expect(scope.showAddressBook()).equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should validate address', function() {
|
it('should validate address with network', function() {
|
||||||
form.newaddress.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
form.newaddress.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
|
||||||
expect(form.newaddress.$invalid).to.equal(false);
|
expect(form.newaddress.$invalid).to.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not validate address', function() {
|
it('should not validate address with other network', function() {
|
||||||
|
form.newaddress.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||||
|
expect(form.newaddress.$invalid).to.equal(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not validate random address', function() {
|
||||||
form.newaddress.$setViewValue('thisisaninvalidaddress');
|
form.newaddress.$setViewValue('thisisaninvalidaddress');
|
||||||
expect(form.newaddress.$invalid).to.equal(true);
|
expect(form.newaddress.$invalid).to.equal(true);
|
||||||
});
|
});
|
||||||
|
@ -194,7 +199,7 @@ describe("Unit: Controllers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a transaction proposal', function() {
|
it('should create a transaction proposal', function() {
|
||||||
sendForm.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
sendForm.address.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
|
||||||
sendForm.amount.$setViewValue(1000);
|
sendForm.amount.$setViewValue(1000);
|
||||||
|
|
||||||
var spy = sinon.spy(scope.wallet, 'createTx');
|
var spy = sinon.spy(scope.wallet, 'createTx');
|
||||||
|
@ -205,7 +210,7 @@ describe("Unit: Controllers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create and send a transaction proposal', function() {
|
it('should create and send a transaction proposal', function() {
|
||||||
sendForm.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
sendForm.address.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
|
||||||
sendForm.amount.$setViewValue(1000);
|
sendForm.amount.$setViewValue(1000);
|
||||||
|
|
||||||
scope.wallet.totalCopayers = scope.wallet.requiredCopayers = 1;
|
scope.wallet.totalCopayers = scope.wallet.requiredCopayers = 1;
|
||||||
|
@ -372,7 +377,7 @@ describe("Unit: Controllers", function() {
|
||||||
var what;
|
var what;
|
||||||
beforeEach(inject(function($controller, $rootScope) {
|
beforeEach(inject(function($controller, $rootScope) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
var routeParams = {
|
var routeParams = {
|
||||||
data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation'
|
data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation'
|
||||||
};
|
};
|
||||||
what = $controller('UriPaymentController', {
|
what = $controller('UriPaymentController', {
|
||||||
|
|
|
@ -36,11 +36,17 @@ describe("Unit: Testing Directives", function() {
|
||||||
form = $scope.form;
|
form = $scope.form;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should validate', function() {
|
it('should validate with network', function() {
|
||||||
|
config.networkName = 'testnet';
|
||||||
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||||
expect(form.address.$invalid).to.equal(false);
|
expect(form.address.$invalid).to.equal(false);
|
||||||
});
|
});
|
||||||
it('should not validate', function() {
|
it('should not validate with other network', function() {
|
||||||
|
config.networkName = 'livenet';
|
||||||
|
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||||
|
expect(form.address.$invalid).to.equal(true);
|
||||||
|
});
|
||||||
|
it('should not validate random', function() {
|
||||||
form.address.$setViewValue('thisisaninvalidaddress');
|
form.address.$setViewValue('thisisaninvalidaddress');
|
||||||
expect(form.address.$invalid).to.equal(true);
|
expect(form.address.$invalid).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue