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

52 lines
1.5 KiB
JavaScript
Raw Normal View History

2014-01-08 11:29:39 -08:00
#!/usr/bin/env node
'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-01-08 11:29:39 -08:00
assert = require('assert'),
config = require('../../config/config'),
2014-02-03 22:22:58 -08:00
BlockDb = require('../../lib/BlockDb').class();
2014-01-08 11:29:39 -08:00
2014-02-03 22:22:58 -08:00
describe('BlockDb fromHashWithInfo', function(){
2014-01-08 12:04:45 -08:00
2014-02-03 22:22:58 -08:00
var bdb = new BlockDb();
2014-01-10 11:02:33 -08:00
it('should poll block\'s info from bitcoind', function(done) {
2014-02-03 22:22:58 -08:00
bdb.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
2014-01-10 11:02:33 -08:00
if (err) done(err);
2014-02-03 22:22:58 -08:00
assert.equal(b2.hash, TESTING_BLOCK);
2014-01-10 11:02:33 -08:00
assert.equal(b2.info.hash, TESTING_BLOCK);
assert.equal(b2.info.chainwork, '000000000000000000000000000000000000000000000000001b6dc969ffe847');
2014-01-10 11:02:33 -08:00
done();
2014-01-08 11:29:39 -08:00
});
});
2014-02-03 22:22:58 -08:00
it('return true in has', function(done) {
bdb.has(TESTING_BLOCK, function(err, has) {
assert.equal(has, true);
done();
});
});
2014-02-04 08:06:05 -08:00
it('setOrphan', function(done) {
var b16 = '00000000c4cbd75af741f3a2b2ff72d9ed4d83a048462c1efe331be31ccf006b';
var b17 = '00000000fe198cce4c8abf9dca0fee1182cb130df966cc428ad2a230df8da743';
bdb.has(b17, function(err, has) {
assert(has);
bdb.setOrphan(b17, function(err, oldPrev) {
assert.equal(oldPrev, b16);
bdb.setPrev(b17, b16, function(err, oldPrev) {
bdb.getPrev(b17, function(err, p) {
assert.equal(p, b16);
done();
});
});
});
2014-02-03 22:22:58 -08:00
});
});
2014-01-08 11:29:39 -08:00
});