From 270413a6554bd56cb017013b477eb7890ce133d9 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 29 Apr 2015 15:54:41 -0300 Subject: [PATCH] add simpler test that fails --- lib/block/block.js | 5 +++-- lib/script/script.js | 1 + test/block.js | 2 +- test/script/script.js | 10 ++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/block/block.js b/lib/block/block.js index 05596d021..487c2d39a 100644 --- a/lib/block/block.js +++ b/lib/block/block.js @@ -68,8 +68,9 @@ Block._fromJSON = function _fromJSON(data) { */ Block._fromObject = function _fromObject(data) { var transactions = []; - data.transactions.forEach(function(data) { - transactions.push(Transaction().fromJSON(data)); + data.transactions.forEach(function(tx) { + console.log(tx.id); + transactions.push(Transaction().fromJSON(tx)); }); var info = { header: BlockHeader.fromObject(data.header), diff --git a/lib/script/script.js b/lib/script/script.js index ed7428a2d..04db39826 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -158,6 +158,7 @@ Script.fromString = function(str) { }); i = i + 2; } else { + console.log(token, opcodenum, i); throw new Error('Invalid script: ' + JSON.stringify(str)); } } else if (opcodenum === Opcode.OP_PUSHDATA1 || diff --git a/test/block.js b/test/block.js index 3eac252eb..56cbad27a 100644 --- a/test/block.js +++ b/test/block.js @@ -120,7 +120,7 @@ describe('Block', function() { }); - describe.only('#fromBuffer', function() { + describe('#fromBuffer', function() { it('should make a block from this known buffer', function() { var block = Block.fromBuffer(blockbuf); diff --git a/test/script/script.js b/test/script/script.js index 54a3d6bfc..b3533f167 100644 --- a/test/script/script.js +++ b/test/script/script.js @@ -754,5 +754,15 @@ describe('Script', function() { Script().add(new Buffer('a')).equals(Script().add(new Buffer('b'))).should.equal(false); }); }); + describe.only('coinbase transaction input script', function() { + it('works for bug found in bitcore-node', function() { + var hex = '03984b05e4b883e5bda9e7a59ee4bb99e9b1bcfabe6d6d5cb348c1c7d580627835202f5ad93c2f3db10bb850a1a513979f8328d9f35aff1000000000000000006189dd01cf00004d696e6564206279207975313333353131373131'; + var s = new Script(hex); + var s2 = new Script(s.toString()); + console.log(s2.toString()); + s2.toString().should.equal(s.toString()); + }); + }); + });