From a87105438725a0f85d59e48e85fc8220b3ec3678 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 19 Apr 2016 04:44:20 -0700 Subject: [PATCH] handle coinbase tests. --- test/tx-test.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/tx-test.js b/test/tx-test.js index 72da1236..1c306399 100644 --- a/test/tx-test.js +++ b/test/tx-test.js @@ -114,13 +114,12 @@ describe('TX', function() { tx.fillCoins(coin); }); - if (!tx.hasCoins()) - return; - return { tx: tx, flags: flags, - comments: tx.inputs[0].coin.script.inspect(), + comments: tx.hasCoins() + ? utils._inspect(tx.inputs[0].coin.script, false).slice(0, -1) + : 'coinbase', data: data }; } @@ -147,10 +146,16 @@ describe('TX', function() { var flags = data.flags; var comments = comment.trim(); if (!comments) - comments = data.comment; + comments = data.comments; comment = ''; if (valid) { + if (comments.indexOf('Coinbase') === 0) { + it('should handle valid coinbase: ' + comments, function () { + assert.ok(tx.isSane()); + }); + return; + } it('should handle valid tx test: ' + comments, function () { assert.ok(tx.verify(null, true, flags)); }); @@ -161,8 +166,14 @@ describe('TX', function() { }); return; } + if (comments.indexOf('Coinbase') === 0) { + it('should handle invalid coinbase: ' + comments, function () { + assert.ok(!tx.isSane()); + }); + return; + } it('should handle invalid tx test: ' + comments, function () { - assert.ok(!tx.verify(null, true, flags)); + assert.ok(!tx.verify(null, true, flags)); }); } });