More tests on TxProposal
This commit is contained in:
parent
1268114b74
commit
a530c27b2e
2 changed files with 29 additions and 6 deletions
|
|
@ -154,12 +154,6 @@ TxProposal.prototype._check = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TxProposal.prototype.trimForStorage = function() {
|
|
||||||
// TODO (remove builder / builderObj. utxos, etc)
|
|
||||||
//
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
TxProposal.prototype.addMerchantData = function(merchantData) {
|
TxProposal.prototype.addMerchantData = function(merchantData) {
|
||||||
preconditions.checkArgument(merchantData.pr);
|
preconditions.checkArgument(merchantData.pr);
|
||||||
preconditions.checkArgument(merchantData.request_url);
|
preconditions.checkArgument(merchantData.request_url);
|
||||||
|
|
|
||||||
|
|
@ -431,6 +431,17 @@ describe('TxProposal', function() {
|
||||||
it('OK', function() {
|
it('OK', function() {
|
||||||
dummyProposal({})._check();
|
dummyProposal({})._check();
|
||||||
});
|
});
|
||||||
|
it('FAIL Invalid tx proposal', function() {
|
||||||
|
var txp = dummyProposal();
|
||||||
|
var old = txp.builder.signhash;
|
||||||
|
txp.builder.signhash = 'ppp';
|
||||||
|
(function() {
|
||||||
|
txp._check();
|
||||||
|
}).should.throw('Invalid tx proposal');
|
||||||
|
|
||||||
|
txp.builder.signhash = old;
|
||||||
|
});
|
||||||
|
|
||||||
it('FAIL ins', function() {
|
it('FAIL ins', function() {
|
||||||
(function() {
|
(function() {
|
||||||
dummyProposal({
|
dummyProposal({
|
||||||
|
|
@ -438,6 +449,24 @@ describe('TxProposal', function() {
|
||||||
})._check();
|
})._check();
|
||||||
}).should.throw('no ins');
|
}).should.throw('no ins');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('FAIL txp too big ', function() {
|
||||||
|
var txp = dummyProposal();
|
||||||
|
var old_builder = txp.builder.build;
|
||||||
|
|
||||||
|
var tx = {
|
||||||
|
getSize: function() {
|
||||||
|
return 90000;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
txp.builder.build = sinon.stub().returns(tx);;
|
||||||
|
(function() {
|
||||||
|
txp._check();
|
||||||
|
}).should.throw('BIG: Invalid TX proposal. Too big');
|
||||||
|
txp.builder.build = old_builder;
|
||||||
|
});
|
||||||
|
|
||||||
it('FAIL signhash SINGLE', function() {
|
it('FAIL signhash SINGLE', function() {
|
||||||
var txp = dummyProposal({
|
var txp = dummyProposal({
|
||||||
hashtype: Transaction.SIGHASH_SINGLE
|
hashtype: Transaction.SIGHASH_SINGLE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue