From dca7a38362010e201b55c5185a204649a698109f Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 29 Sep 2015 18:41:58 +1000 Subject: [PATCH] tests: remove unnecessary branch, fix bscript.fromHex undefined --- test/script.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/script.js b/test/script.js index b8e43eb..ccb009f 100644 --- a/test/script.js +++ b/test/script.js @@ -149,19 +149,17 @@ describe('script', function () { if (!(inputFnName in fixtures.invalid)) return fixtures.invalid[inputFnName].forEach(function (f) { - if (inputFn && (f.scriptSig || f.scriptSigHex)) { - it('returns false for ' + f.description + ' (' + (f.scriptSig || f.scriptSigHex) + ')', function () { - var scriptSig + it('returns false for ' + f.description + ' (' + (f.scriptSig || f.scriptSigHex) + ')', function () { + var scriptSig - if (f.scriptSig) { - scriptSig = bscript.fromASM(f.scriptSig) - } else { - scriptSig = bscript.fromHex(f.scriptSigHex) - } + if (f.scriptSig) { + scriptSig = bscript.fromASM(f.scriptSig) + } else { + scriptSig = new Buffer(f.scriptSigHex, 'hex') + } - assert.strictEqual(inputFn(scriptSig), false) - }) - } + assert.strictEqual(inputFn(scriptSig), false) + }) }) }) @@ -181,13 +179,17 @@ describe('script', function () { if (!(outputFnName in fixtures.invalid)) return fixtures.invalid[outputFnName].forEach(function (f) { - if (outputFn && f.scriptPubKey) { - it('returns false for ' + f.description + ' (' + f.scriptPubKey + ')', function () { - var scriptPubKey = bscript.fromASM(f.scriptPubKey) + it('returns false for ' + f.description + ' (' + (f.scriptPubKey || f.scriptPubKeyHex) + ')', function () { + var scriptPubKey - assert.strictEqual(outputFn(scriptPubKey), false) - }) - } + if (f.scriptPubKey) { + scriptPubKey = bscript.fromASM(f.scriptPubKey) + } else { + scriptPubKey = new Buffer(f.scriptPubKeyHex, 'hex') + } + + assert.strictEqual(outputFn(scriptPubKey), false) + }) }) }) })