Less repetition on tests for skipping serialization checks
This commit is contained in:
parent
684dfd5283
commit
427c9b3234
|
@ -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() {
|
||||||
|
var buildSkipTest = function(builder, check) {
|
||||||
|
return function() {
|
||||||
|
var transaction = new Transaction();
|
||||||
|
transaction.from(simpleUtxoWith1BTC)
|
||||||
|
builder(transaction);
|
||||||
|
|
||||||
|
var options = {};
|
||||||
|
options[check] = true;
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
return transaction.serialize(options);
|
||||||
|
}).not.to.throw();
|
||||||
|
expect(function() {
|
||||||
|
return transaction.serialize();
|
||||||
|
}).to.throw();
|
||||||
|
};
|
||||||
|
};
|
||||||
it('can skip the check for too much fee', function() {
|
it('can skip the check for too much fee', function() {
|
||||||
var transaction = new Transaction()
|
buildSkipTest(function(transaction) {
|
||||||
.from(simpleUtxoWith1BTC)
|
return transaction
|
||||||
.fee(50000000)
|
.fee(50000000)
|
||||||
.change(changeAddress)
|
.change(changeAddress)
|
||||||
.sign(privateKey);
|
.sign(privateKey);
|
||||||
expect(function() {
|
}, 'disableLargeFees');
|
||||||
return transaction.serialize({disableLargeFees: true});
|
|
||||||
}).to.not.throw();
|
|
||||||
expect(function() {
|
|
||||||
return transaction.serialize();
|
|
||||||
}).to.throw();
|
|
||||||
});
|
});
|
||||||
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…
Reference in New Issue