Skip to content

Commit abf922e

Browse files
committed
tests: less ambiguous naming, fix exception check
1 parent ac4b9d5 commit abf922e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

test/transaction.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,28 @@ describe('Transaction', function () {
213213
})
214214

215215
describe('hashForSignature', function () {
216-
it('only uses V0 serialization', function () {
216+
it('only uses legacy serialization', function () {
217217
var randScript = new Buffer('6a', 'hex')
218218

219-
var tmp = new Transaction()
220-
tmp.addInput(new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 0)
221-
tmp.addOutput(randScript, 5000000000)
222-
tmp.___toBuffer = tmp.__toBuffer
223-
tmp.__toBuffer = function (a, b, c) {
224-
if (c !== false) {
225-
throw new Error('Not meant to pass true to __toBuffer in hashForSignature')
226-
}
227-
return this.___toBuffer(a, b, c)
219+
var tx = new Transaction()
220+
tx.addInput(new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 0)
221+
tx.addOutput(randScript, 5000000000)
222+
223+
var original = tx.__toBuffer
224+
tx.__toBuffer = function (a, b, c) {
225+
if (c !== false) throw new Error('hashForSignature MUST pass false')
226+
227+
return original.call(this, a, b, c)
228228
}
229229

230230
assert.throws(function () {
231-
tmp.__toBuffer(undefined, undefined, true)
232-
}, 'Verify our replacement of __toBuffer can lead to an error if using witness')
231+
tx.__toBuffer(undefined, undefined, true)
232+
}, /hashForSignature MUST pass false/)
233233

234+
// assert hashForSignature does not pass false
234235
assert.doesNotThrow(function () {
235-
tmp.hashForSignature(0, randScript, 1)
236-
}, "check that this situation doesn't occur normally")
236+
tx.hashForSignature(0, randScript, 1)
237+
})
237238
})
238239

239240
fixtures.hashForSignature.forEach(function (f) {

0 commit comments

Comments
 (0)