From f3138dcb6859b880e7e025586b96085d11cb2c30 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 13 Oct 2014 19:51:13 +1100 Subject: [PATCH] tests: test non-standard pathway for classifyInput --- test/fixtures/scripts.json | 4 ++++ test/scripts.js | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/test/fixtures/scripts.json b/test/fixtures/scripts.json index aa5d29e..cd69470 100644 --- a/test/fixtures/scripts.json +++ b/test/fixtures/scripts.json @@ -95,6 +95,10 @@ { "description": "multisig output : non-canonical pubKey (bad length)", "scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ffff OP_1 OP_CHECKMULTISIG" + }, + { + "description": "pubKeyHash input : extraneous data", + "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 ffffffff" } ], "multisig": [ diff --git a/test/scripts.js b/test/scripts.js index b50ec3a..9709ec9 100644 --- a/test/scripts.js +++ b/test/scripts.js @@ -19,6 +19,17 @@ describe('Scripts', function() { assert.equal(type, f.type) }) }) + + fixtures.invalid.classify.forEach(function(f) { + if (!f.scriptSig) return + + it('returns nonstandard for ' + f.description, function() { + var script = Script.fromASM(f.scriptSig) + var type = scripts.classifyInput(script) + + assert.equal(type, 'nonstandard') + }) + }) }) describe('classifyOutput', function() { @@ -34,6 +45,8 @@ describe('Scripts', function() { }) fixtures.invalid.classify.forEach(function(f) { + if (!f.scriptPubKey) return + it('returns nonstandard for ' + f.description, function() { var script = Script.fromASM(f.scriptPubKey) var type = scripts.classifyOutput(script)