Browse Source

Merge pull request #1111 from eordano/serialize/checks

Minor: Less repetition on tests for skipping serialization checks
patch-2
Manuel Aráoz 10 years ago
parent
commit
5e08fcdfff
  1. 61
      test/transaction/transaction.js

61
test/transaction/transaction.js

@ -340,56 +340,53 @@ describe('Transaction', function() {
}).to.not.throw(errors.Transaction.DustOutputs); }).to.not.throw(errors.Transaction.DustOutputs);
}); });
describe('skipping checks', function() { describe('skipping checks', function() {
it('can skip the check for too much fee', function() { var buildSkipTest = function(builder, check) {
var transaction = new Transaction() return function() {
.from(simpleUtxoWith1BTC) var transaction = new Transaction();
.fee(50000000) transaction.from(simpleUtxoWith1BTC)
.change(changeAddress) builder(transaction);
.sign(privateKey);
var options = {};
options[check] = true;
expect(function() { expect(function() {
return transaction.serialize({disableLargeFees: true}); return transaction.serialize(options);
}).to.not.throw(); }).not.to.throw();
expect(function() { expect(function() {
return transaction.serialize(); return transaction.serialize();
}).to.throw(); }).to.throw();
};
};
it('can skip the check for too much fee', function() {
buildSkipTest(function(transaction) {
return transaction
.fee(50000000)
.change(changeAddress)
.sign(privateKey);
}, 'disableLargeFees');
}); });
it('can skip the check for a fee that is too small', function() { it('can skip the check for a fee that is too small', function() {
var transaction = new Transaction() buildSkipTest(function(transaction) {
.from(simpleUtxoWith1BTC) return transaction
.fee(1) .fee(1)
.change(changeAddress) .change(changeAddress)
.sign(privateKey); .sign(privateKey);
expect(function() { }, 'disableSmallFees');
return transaction.serialize({disableSmallFees: true});
}).to.not.throw();
expect(function() {
return transaction.serialize();
}).to.throw();
}); });
it('can skip the check that prevents dust outputs', function() { it('can skip the check that prevents dust outputs', function() {
var transaction = new Transaction() buildSkipTest(function(transaction) {
.from(simpleUtxoWith1BTC) return transaction
.to(toAddress, 1000) .to(toAddress, 1000)
.change(changeAddress) .change(changeAddress)
.sign(privateKey); .sign(privateKey);
expect(function() { }, 'disableDustOutputs');
return transaction.serialize({disableDustOutputs: true});
}).to.not.throw();
expect(function() {
return transaction.serialize();
}).to.throw();
}); });
it('can skip the check that prevents unsigned outputs', function() { it('can skip the check that prevents unsigned outputs', function() {
var transaction = new Transaction() buildSkipTest(function(transaction) {
.from(simpleUtxoWith1BTC) return transaction
.to(toAddress, 10000) .to(toAddress, 10000)
.change(changeAddress); .change(changeAddress);
expect(function() { }, 'disableIsFullySigned');
return transaction.serialize({disableIsFullySigned: true});
}).to.not.throw();
expect(function() {
return transaction.serialize();
}).to.throw();
}); });
}); });
}); });

Loading…
Cancel
Save