block integration test fixed
This commit is contained in:
parent
8edf753883
commit
9f6e340364
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -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(){
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue