From 4bcd169f6d03c41e219a20cbf5610f75fab071e0 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sun, 15 Feb 2015 21:21:01 +1100 Subject: [PATCH] tests: actually run invalid tests --- test/scripts.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/test/scripts.js b/test/scripts.js index fae41df..13ebe1a 100644 --- a/test/scripts.js +++ b/test/scripts.js @@ -51,8 +51,11 @@ describe('Scripts', function() { }) ;['PubKey', 'PubKeyHash', 'ScriptHash', 'Multisig', 'NullData'].forEach(function(type) { - var inputFn = scripts['is' + type + 'Input'] - var outputFn= scripts['is' + type + 'Output'] + var inputFnName = 'is' + type + 'Input' + var outputFnName = 'is' + type + 'Output' + + var inputFn = scripts[inputFnName] + var outputFn= scripts[outputFnName] describe('is' + type + 'Input', function() { fixtures.valid.forEach(function(f) { @@ -76,6 +79,18 @@ describe('Scripts', function() { } } }) + + if (!(inputFnName in fixtures.invalid)) return + + fixtures.invalid[inputFnName].forEach(function(f) { + if (inputFn && f.scriptSig) { + it('returns false for ' + f.scriptSig, function() { + var script = Script.fromASM(f.scriptSig) + + assert.equal(inputFn(script), false) + }) + } + }) }) describe('is' + type + 'Output', function() { @@ -90,6 +105,18 @@ describe('Scripts', function() { }) } }) + + if (!(outputFnName in fixtures.invalid)) return + + fixtures.invalid[outputFnName].forEach(function(f) { + if (outputFn && f.scriptPubKey) { + it('returns false for ' + f.scriptPubKey, function() { + var script = Script.fromASM(f.scriptPubKey) + + assert.equal(outputFn(script), false) + }) + } + }) }) })