Browse Source

tests: less ambiguous naming, fix exception check

hk-custom-address
Daniel Cousens 8 years ago
committed by Daniel Cousens
parent
commit
abf922e808
  1. 29
      test/transaction.js

29
test/transaction.js

@ -213,27 +213,28 @@ describe('Transaction', function () {
}) })
describe('hashForSignature', function () { describe('hashForSignature', function () {
it('only uses V0 serialization', function () { it('only uses legacy serialization', function () {
var randScript = new Buffer('6a', 'hex') var randScript = new Buffer('6a', 'hex')
var tmp = new Transaction() var tx = new Transaction()
tmp.addInput(new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 0) tx.addInput(new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 0)
tmp.addOutput(randScript, 5000000000) tx.addOutput(randScript, 5000000000)
tmp.___toBuffer = tmp.__toBuffer
tmp.__toBuffer = function (a, b, c) { var original = tx.__toBuffer
if (c !== false) { tx.__toBuffer = function (a, b, c) {
throw new Error('Not meant to pass true to __toBuffer in hashForSignature') if (c !== false) throw new Error('hashForSignature MUST pass false')
}
return this.___toBuffer(a, b, c) return original.call(this, a, b, c)
} }
assert.throws(function () { assert.throws(function () {
tmp.__toBuffer(undefined, undefined, true) tx.__toBuffer(undefined, undefined, true)
}, 'Verify our replacement of __toBuffer can lead to an error if using witness') }, /hashForSignature MUST pass false/)
// assert hashForSignature does not pass false
assert.doesNotThrow(function () { assert.doesNotThrow(function () {
tmp.hashForSignature(0, randScript, 1) tx.hashForSignature(0, randScript, 1)
}, "check that this situation doesn't occur normally") })
}) })
fixtures.hashForSignature.forEach(function (f) { fixtures.hashForSignature.forEach(function (f) {

Loading…
Cancel
Save