tests: add [failing] test for nulldata signing

This commit is contained in:
Daniel Cousens 2015-01-06 11:00:49 +11:00
parent 35fa86c1f9
commit 396e4d4235
2 changed files with 45 additions and 1 deletions

View file

@ -187,7 +187,9 @@
"value": 1000
}
]
},
}
],
"sign": [
{
"exception": "nulldata not supported",
"inputs": [
@ -195,6 +197,7 @@
"index": 0,
"prevTx": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"prevTxScript": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
"throws": true,
"privKeys": [
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
]

View file

@ -205,6 +205,47 @@ describe('TransactionBuilder', function() {
txb.sign(0, ECKey.makeRandom(), redeemScript)
}, /privateKey cannot sign for this input/)
})
fixtures.invalid.sign.forEach(function(f) {
it('throws on ' + f.exception, function() {
f.inputs.forEach(function(input) {
var prevTxScript
if (input.prevTxScript) {
prevTxScript = Script.fromASM(input.prevTxScript)
}
txb.addInput(input.prevTx, input.index, input.sequence, prevTxScript)
})
f.outputs.forEach(function(output) {
var script = Script.fromASM(output.script)
txb.addOutput(script, output.value)
})
f.inputs.forEach(function(input, index) {
var redeemScript
if (input.redeemScript) {
redeemScript = Script.fromASM(input.redeemScript)
}
input.privKeys.forEach(function(wif) {
var privKey = ECKey.fromWIF(wif)
if (!input.throws) {
txb.sign(index, privKey, redeemScript)
} else {
assert.throws(function() {
txb.sign(index, privKey, redeemScript)
}, new RegExp(f.exception))
}
})
})
})
})
})
describe('build', function() {