Browse Source

tests: add [failing] test for nulldata signing

hk-custom-address
Daniel Cousens 10 years ago
parent
commit
396e4d4235
  1. 5
      test/fixtures/transaction_builder.json
  2. 41
      test/transaction_builder.js

5
test/fixtures/transaction_builder.json

@ -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"
]

41
test/transaction_builder.js

@ -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() {

Loading…
Cancel
Save