insight-ui-zcash/test/integration/block.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-01-08 11:29:39 -08:00
#!/usr/bin/env node
2014-02-11 08:02:28 -08:00
'use strict';
2014-01-08 11:29:39 -08:00
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var TESTING_BLOCK = '000000000185678d3d7ecc9962c96418174431f93fe20bf216d5565272423f74';
2014-01-08 11:29:39 -08:00
var
2014-02-11 08:02:28 -08:00
assert = require('assert'),
// config = require('../../config/config'),
BlockDb = require('../../lib/BlockDb').class();
2014-01-08 11:29:39 -08:00
2014-02-05 06:23:41 -08:00
var bDb;
2014-01-08 11:29:39 -08:00
2014-02-11 08:02:28 -08:00
describe('BlockDb fromHashWithInfo', function() {
2014-02-05 06:23:41 -08:00
before(function(c) {
bDb = new BlockDb();
return c();
});
2014-01-10 11:02:33 -08:00
it('should poll block\'s info from bitcoind', function(done) {
2014-02-05 06:23:41 -08:00
bDb.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
2014-02-11 08:02:28 -08:00
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();
2014-01-08 11:29:39 -08:00
});
});
2014-02-03 22:22:58 -08:00
it('return true in has', function(done) {
2014-02-05 06:23:41 -08:00
bDb.has(TESTING_BLOCK, function(err, has) {
2014-02-03 22:22:58 -08:00
assert.equal(has, true);
done();
});
});
2014-01-08 11:29:39 -08:00
});