fix tests

This commit is contained in:
Manuel Araoz 2014-07-04 12:51:27 -03:00
parent 90ebd8deb5
commit a30b8d81bb
5 changed files with 43 additions and 16 deletions

View File

@ -29,8 +29,7 @@ angular.module('copayApp.directives')
restrict: 'A',
link: function(scope, element, attrs, ctrl) {
setTimeout(function() {
scope.$apply(function() {
});
scope.$apply(function() {});
}, 5000);
}
};

View File

@ -697,8 +697,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
opts = opts || {};
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()) {
throw new Error('publicKeyRing is not complete');
}

View File

@ -172,6 +172,24 @@ describe('Wallet model', function() {
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() {
var w = cachedCreateW2();
@ -180,7 +198,7 @@ describe('Wallet model', function() {
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
var ntxid = w.createTxSync(
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123456789',
null,
unspentTest
@ -205,7 +223,7 @@ describe('Wallet model', function() {
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
var ntxid = w.createTxSync(
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123456789',
comment,
unspentTest
@ -228,7 +246,7 @@ describe('Wallet model', function() {
var badCreate = function() {
w.createTxSync(
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123456789',
comment,
unspentTest
@ -262,7 +280,7 @@ describe('Wallet model', function() {
unspentTest[0].address = w.publicKeyRing.getAddress(index, isChange).toString();
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(index, isChange);
w.createTxSync(
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123456789',
null,
unspentTest

View File

@ -174,12 +174,17 @@ describe("Unit: Controllers", function() {
expect(scope.showAddressBook()).equal(true);
});
it('should validate address', function() {
form.newaddress.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
it('should validate address with network', function() {
form.newaddress.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
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');
expect(form.newaddress.$invalid).to.equal(true);
});
@ -194,7 +199,7 @@ describe("Unit: Controllers", function() {
});
it('should create a transaction proposal', function() {
sendForm.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
sendForm.address.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
sendForm.amount.$setViewValue(1000);
var spy = sinon.spy(scope.wallet, 'createTx');
@ -205,7 +210,7 @@ describe("Unit: Controllers", function() {
});
it('should create and send a transaction proposal', function() {
sendForm.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
sendForm.address.$setViewValue('1JqniWpWNA6Yvdivg3y9izLidETnurxRQm');
sendForm.amount.$setViewValue(1000);
scope.wallet.totalCopayers = scope.wallet.requiredCopayers = 1;
@ -372,7 +377,7 @@ describe("Unit: Controllers", function() {
var what;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
var routeParams = {
var routeParams = {
data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation'
};
what = $controller('UriPaymentController', {

View File

@ -36,11 +36,17 @@ describe("Unit: Testing Directives", function() {
form = $scope.form;
}));
it('should validate', function() {
it('should validate with network', function() {
config.networkName = 'testnet';
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
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');
expect(form.address.$invalid).to.equal(true);
});