Add test for TxProposal

This commit is contained in:
Matias Pando 2015-01-23 12:08:09 -03:00
parent 503895fe6c
commit 63b4f2c649
2 changed files with 50 additions and 12 deletions

View File

@ -74,6 +74,7 @@ describe('HDParams model', function() {
});
it('should count generation indexes', function() {
var j = new HDParams();
j.copayerIndex = 1;
@ -121,3 +122,28 @@ describe('HDParams model', function() {
})
});
describe('#checkRange', function() {
it('should throw an error', function() {
var hd = new HDParams();
(function() {
hd.checkRange(60, true);
}).should.throw('Out of bounds');
});
it('should throw an error', function() {
var hd = new HDParams();
(function() {
hd.checkRange(60, false);
}).should.throw('Out of bounds');
});
it('should not throw an error', function() {
var hd = new HDParams();
hd.checkRange(0, false);
hd.checkRange(0, true);
});
});

View File

@ -368,6 +368,18 @@ describe('TxProposal', function() {
txp.builder.inputsSigned.should.be.equal(0);
});
it.only('should not add signatures to complete txs ', function() {
var txp = dummyProposal({
nsig: 1
});
txp.addSignature('pepe', [SIG1]);
txp.builder.inputsSigned.should.be.equal(0);
var r = txp.addSignature('lolo', [SIG0]);
r.should.be.false;
txp.builder.inputsSigned.should.be.equal(0);
});
it('should fail with invalid signatures', function() {
var txp = dummyProposal({
nsig: 1