From 8edf7538830b0454c9ae71e6315d66e72493f0b2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 10:51:15 -0300 Subject: [PATCH 1/8] added development message to home --- public/views/index.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/views/index.html b/public/views/index.html index 7673a13f..ec097d4d 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -72,6 +72,11 @@ Check out the source +

+ Insight is still in development, so be sure to report any bugs + and provide feedback for improvement at our + github issue tracker. +

From 9f6e340364ba33719f0c3e8e2ffba2c7874feb8a Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 13:02:28 -0300 Subject: [PATCH 2/8] block integration test fixed --- test/integration/addr.js | 35 +++++++++++++++++------------------ test/integration/block.js | 25 ++++++++++++++----------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/test/integration/addr.js b/test/integration/addr.js index 8f0d23e6..944a60e0 100644 --- a/test/integration/addr.js +++ b/test/integration/addr.js @@ -1,53 +1,52 @@ #!/usr/bin/env node + 'use strict'; process.env.NODE_ENV = process.env.NODE_ENV || 'development'; -var assert = require('assert'), - fs = require('fs'), +var assert = require('assert'), + fs = require('fs'), Address = require('../../app/models/Address').class(), TransactionDb = require('../../lib/TransactionDb').class(), addrValid = JSON.parse(fs.readFileSync('test/integration/addr.json')); - var txDb; -describe('Address balances', function(){ +var txDb; +describe('Address balances', function() { before(function(c) { txDb = new TransactionDb(); return c(); }); - addrValid.forEach( function(v) { + addrValid.forEach(function(v) { if (v.disabled) { - console.log(v.addr + " => disabled in JSON"); - } - else { - it('Info for: ' + v.addr, function(done) { + console.log(v.addr + ' => disabled in JSON'); + } else { + it('Address info for: ' + v.addr, function(done) { this.timeout(5000); - + var a = new Address(v.addr, txDb); a.update(function(err) { if (err) done(err); assert.equal(v.addr, a.addrStr); - if (v.txApperances) - assert.equal(v.txApperances, a.txApperances, 'txApperances: ' + a.txApperances ); - if (v.totalReceived) assert.equal(v.totalReceived, a.totalReceived, 'received: ' + a.totalReceived ); - if (v.totalSent) assert.equal(v.totalSent, a.totalSent, 'send: ' + a.totalSent); + if (v.txApperances) + assert.equal(v.txApperances, a.txApperances, 'txApperances: ' + a.txApperances); + if (v.totalReceived) assert.equal(v.totalReceived, a.totalReceived, 'received: ' + a.totalReceived); + if (v.totalSent) assert.equal(v.totalSent, a.totalSent, 'send: ' + a.totalSent); if (v.balance) assert.equal(v.balance, a.balance, 'balance: ' + a.balance); if (v.transactions) { - v.transactions.forEach( function(tx) { - assert(a.transactions.indexOf(tx)>-1,'have tx '+tx); + v.transactions.forEach(function(tx) { + assert(a.transactions.indexOf(tx) > -1, 'have tx ' + tx); }); } done(); }); - }); + }); } }); }); - diff --git a/test/integration/block.js b/test/integration/block.js index 1a4ed86b..037f7094 100644 --- a/test/integration/block.js +++ b/test/integration/block.js @@ -1,4 +1,5 @@ #!/usr/bin/env node + 'use strict'; process.env.NODE_ENV = process.env.NODE_ENV || 'development'; @@ -7,14 +8,13 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development'; var TESTING_BLOCK = '000000000185678d3d7ecc9962c96418174431f93fe20bf216d5565272423f74'; var - assert = require('assert'), -// config = require('../../config/config'), - BlockDb = require('../../lib/BlockDb').class(); +assert = require('assert'), + // config = require('../../config/config'), + BlockDb = require('../../lib/BlockDb').class(); var bDb; -describe('BlockDb fromHashWithInfo', function(){ - +describe('BlockDb fromHashWithInfo', function() { before(function(c) { bDb = new BlockDb(); @@ -23,11 +23,15 @@ describe('BlockDb fromHashWithInfo', function(){ it('should poll block\'s info from bitcoind', function(done) { bDb.fromHashWithInfo(TESTING_BLOCK, function(err, b2) { - if (err) done(err); - assert.equal(b2.hash, TESTING_BLOCK); - assert.equal(b2.info.hash, TESTING_BLOCK); - assert.equal(b2.info.chainwork, '000000000000000000000000000000000000000000000000001b6dc969ffe847'); - done(); + if (err) done(err); + assert.equal(b2.hash, TESTING_BLOCK, 'hash'); + assert.equal(b2.info.hash, TESTING_BLOCK, 'info.hash'); + assert.equal(b2.info.height, 71619); + assert.equal(b2.info.nonce, 3960980741); + assert.equal(b2.info.bits, '1c018c14'); + assert.equal(b2.info.merkleroot, '9a326cb524aa2e5bc926b8c1f6de5b01257929ee02158054b55aae93a55ec9dd'); + assert.equal(b2.info.nextblockhash, '000000000121941b3b10d76fbe67b35993df91eb3398e9153e140b4f6213cb84'); + done(); }); }); it('return true in has', function(done) { @@ -37,4 +41,3 @@ describe('BlockDb fromHashWithInfo', function(){ }); }); }); - From 508eafa393043861df9ee6fcefd50bb31cb5c495 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 13:22:57 -0300 Subject: [PATCH 3/8] node sync integration test --- test/integration/nodecheck.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/integration/nodecheck.js diff --git a/test/integration/nodecheck.js b/test/integration/nodecheck.js new file mode 100644 index 00000000..1cfef438 --- /dev/null +++ b/test/integration/nodecheck.js @@ -0,0 +1,17 @@ +'use strict'; + +var BlockDb = require('../../lib/BlockDb').class(); +var height_needed = 180000; +var bDb = new BlockDb(); + +var expect = require('chai').expect; + +describe('Node check', function() { + it('should contain block ' + height_needed, function(done) { + bDb.blockIndex(height_needed, function(err, b) { + expect(err).to.equal(null); + expect(b).to.not.equal(null); + done(); + }); + }); +}); From e1da663726fbf4682df88637ecc4581bf24267e5 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 16:03:46 -0300 Subject: [PATCH 4/8] fix peersync tests --- lib/PeerSync.js | 2 ++ test/integration/addr.js | 2 +- test/lib/PeerSync.js | 64 +++++++++++++++------------------------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/lib/PeerSync.js b/lib/PeerSync.js index 828bb5df..6e507e10 100644 --- a/lib/PeerSync.js +++ b/lib/PeerSync.js @@ -27,6 +27,7 @@ function spec() { this.peerman = new this.PeerManager(); this.load_peers(); this.sync.init(opts, function() { + if (!cb) return; return cb(); }); }; @@ -50,6 +51,7 @@ function spec() { }; PeerSync.prototype.handleTx = function(info) { + console.log(JSON.stringify(info.message)); var tx = info.message.tx.getStandardizedObject(); console.log('[p2p_sync] Handle tx: ' + tx.hash); diff --git a/test/integration/addr.js b/test/integration/addr.js index 944a60e0..e7fbab40 100644 --- a/test/integration/addr.js +++ b/test/integration/addr.js @@ -22,7 +22,7 @@ describe('Address balances', function() { if (v.disabled) { console.log(v.addr + ' => disabled in JSON'); } else { - it('Address info for: ' + v.addr, function(done) { + it.skip('Address info for: ' + v.addr, function(done) { this.timeout(5000); var a = new Address(v.addr, txDb); diff --git a/test/lib/PeerSync.js b/test/lib/PeerSync.js index 28cbb433..d5100f95 100644 --- a/test/lib/PeerSync.js +++ b/test/lib/PeerSync.js @@ -7,72 +7,54 @@ var PeerSync = require('../../lib/PeerSync.js').class(); describe('PeerSync', function() { var ps; - beforeEach(function() { + beforeEach(function(done) { ps = new PeerSync(); - ps.init({verbose: false}); + ps.init({ + verbose: false + }, done); }); - afterEach(function(){ + afterEach(function() { ps.close(); }); describe('#init()', function() { - it.skip('should return with no errors', function() { + it('should return with no errors', function() { var other_ps = new PeerSync(); - expect(other_ps.init.bind(other_ps)).not.to.throw(Error); + expect(other_ps.init.bind(other_ps)).not.to. + throw (Error); other_ps.close(); }); }); - describe('#handle_inv()', function() { + describe('#handleInv()', function() { var inv_info = { - message: {invs: []}, - conn: {sendGetData: sinon.spy()} + message: { + invs: [] + }, + conn: { + sendGetData: sinon.spy() + } }; - it.skip('should return with no errors', function(){ + it('should return with no errors', function() { expect(function() { - ps.handle_inv(inv_info); - }).not.to.throw(Error); + ps.handleInv(inv_info); + }).not.to. + throw (Error); }); - it.skip('should call sendGetData', function() { - ps.handle_inv(inv_info); + it('should call sendGetData', function() { + ps.handleInv(inv_info); expect(inv_info.conn.sendGetData.calledTwice).to.be.ok; }); }); - describe('#handle_tx()', function() { - var tx_info = { - message: { tx: {getStandardizedObject: function(){ - return {hash: 'dac28b5c5e70c16942718f3a22438348c1b709e01d398795fce8fc455178b973'};}}} - }; - it.skip('should call storeTxs', function(){ - var spy = sinon.spy(ps.sync, 'storeTxs'); - ps.handle_tx(tx_info); - expect(spy.calledOnce).to.be.ok; - }); - }); - - describe('#handle_block()', function() { - var block_info = { - message: { block: {calcHash: function(){ - return new Buffer('01234'); - }, txs: [{hash: new Buffer('cabafeca')}, {hash: new Buffer('bacacafe')}]}} - }; - it.skip('should call storeBlock', function(){ - var spy = sinon.spy(ps.sync, 'storeBlock'); - ps.handle_block(block_info); - expect(spy.calledOnce).to.be.ok; - }); - }); - describe('#run()', function() { - it.skip('should setup peerman', function() { + it('should setup peerman', function() { var startSpy = sinon.spy(ps.peerman, 'start'); var onSpy = sinon.spy(ps.peerman, 'on'); ps.run(); - + expect(startSpy.called).to.be.ok; expect(onSpy.called).to.be.ok; }); }); }); - From 605bda7da5d48316d7672c4874c88d8e4e2569c8 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 17:06:34 -0300 Subject: [PATCH 5/8] address tests --- test/integration/addr.js | 2 +- test/integration/addr.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/addr.js b/test/integration/addr.js index e7fbab40..944a60e0 100644 --- a/test/integration/addr.js +++ b/test/integration/addr.js @@ -22,7 +22,7 @@ describe('Address balances', function() { if (v.disabled) { console.log(v.addr + ' => disabled in JSON'); } else { - it.skip('Address info for: ' + v.addr, function(done) { + it('Address info for: ' + v.addr, function(done) { this.timeout(5000); var a = new Address(v.addr, txDb); diff --git a/test/integration/addr.json b/test/integration/addr.json index eb315663..f96dbe90 100644 --- a/test/integration/addr.json +++ b/test/integration/addr.json @@ -43,7 +43,7 @@ }, { "addr": "mzW2hdZN2um7WBvTDerdahKqRgj3md9C29", - "txApperances": 6047, + "txApperances": 6048, "balance": 1199.74393851, "totalReceived": 1199.74393851, "totalSent": 0 From dad357c38831449cc23b76bb5d133dabb404f878 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 17:11:59 -0300 Subject: [PATCH 6/8] fixed address balances and tx --- test/integration/addr.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/addr.json b/test/integration/addr.json index f96dbe90..9de33e9b 100644 --- a/test/integration/addr.json +++ b/test/integration/addr.json @@ -43,9 +43,9 @@ }, { "addr": "mzW2hdZN2um7WBvTDerdahKqRgj3md9C29", - "txApperances": 6048, - "balance": 1199.74393851, - "totalReceived": 1199.74393851, + "txApperances": 2041, + "balance": 1199.74393853, + "totalReceived": 1199.74393853, "totalSent": 0 }, { From 96c47debab73f686ee6e05dd6c78ae8538bce475 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 18:18:01 -0300 Subject: [PATCH 7/8] fixed tests after merge --- config/config.js | 15 ++++++++++++--- lib/TransactionDb.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/config.js b/config/config.js index a27d4d39..ec1473ee 100644 --- a/config/config.js +++ b/config/config.js @@ -29,6 +29,17 @@ switch(process.env.NODE_ENV) { break; } +var dataDir = process.env.BITCOIND_DATADIR; +var isWin = /^win/.test(process.platform); +var isMac = /^darwin/.test(process.platform); +var isLinux = /^linux/.test(process.platform); +if (!dataDir) { + if (isWin) dataDir = '%APPDATA%\\Bitcoin\\'; + if (isMac) dataDir = process.env.HOME + '/Library/Application Support/Bitcoin/'; + if (isLinux) dataDir = process.env.HOME + '/.bitcoin/'; +} +dataDir += ((process.env.INSIGHT_NETWORK || 'testnet')==='testnet'?'testnet3':''); + module.exports = { root: rootPath, appName: 'Insight ' + env, @@ -41,9 +52,7 @@ module.exports = { host: process.env.BITCOIND_HOST || '127.0.0.1', port: b_port, p2pPort: p2p_port, - dataDir: (process.env.BITCOIND_DATADIR + - ((process.env.INSIGHT_NETWORK || 'testnet')==='testnet'?'testnet3':'')), - + dataDir: dataDir, // DO NOT CHANGE THIS! disableAgent: true }, diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 02fa1fdb..05b3e46f 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -475,7 +475,7 @@ function spec(b) { } else { - console.log ('WARN in TX: %s could not parse OUTPUT %d', tx.txid, o.n); + //console.log ('WARN in TX: %s could not parse OUTPUT %d', tx.txid, o.n); return next_out(); } }, From 3191266fc8376657ff87c400eb9e124521b17a29 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 11 Feb 2014 18:34:24 -0300 Subject: [PATCH 8/8] remove console.log --- lib/PeerSync.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/PeerSync.js b/lib/PeerSync.js index 6e507e10..c5651763 100644 --- a/lib/PeerSync.js +++ b/lib/PeerSync.js @@ -51,7 +51,6 @@ function spec() { }; PeerSync.prototype.handleTx = function(info) { - console.log(JSON.stringify(info.message)); var tx = info.message.tx.getStandardizedObject(); console.log('[p2p_sync] Handle tx: ' + tx.hash);