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

75 lines
1.8 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
mongoose= require('mongoose'),
assert = require('assert'),
config = require('../../config/config'),
Block = require('../../app/models/Block');
2014-01-10 11:02:33 -08:00
mongoose.connection.on('error', function(err) { console.log(err); });
2014-01-08 11:29:39 -08:00
describe('Block fromHashWithInfo', function(){
2014-01-08 11:29:39 -08:00
2014-01-10 11:02:33 -08:00
before(function(done) {
mongoose.connect(config.db);
done();
});
2014-01-08 11:29:39 -08:00
2014-01-08 11:46:56 -08:00
after(function(done) {
mongoose.connection.close();
done();
});
2014-01-08 11:29:39 -08:00
2014-01-09 14:49:48 -08:00
2014-01-08 12:04:45 -08:00
it('should poll block\'s info from mongoose', function(done) {
Block.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
2014-01-08 11:46:56 -08:00
if (err) done(err);
2014-01-08 11:29:39 -08:00
var h = new Buffer(TESTING_BLOCK,'hex');
assert(b2.hashStr === TESTING_BLOCK);
assert.equal(b2.hashStr, TESTING_BLOCK);
2014-01-08 12:04:45 -08:00
done();
});
});
2014-01-10 11:02:33 -08:00
it('should poll block\'s info from bitcoind', function(done) {
Block.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
2014-01-10 11:02:33 -08:00
if (err) done(err);
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
});
});
it('hash Virtuals SET', function(done) {
var b = new Block();
b.hashStr = 'a1a2';
assert.equal(b.hash.toString('hex'),'a1a2');
b.nextBlockHashStr = 'a1a3';
assert.equal(b.nextBlockHash.toString('hex'),'a1a3');
done();
});
it('hash Virtuals GET', function(done) {
var b = new Block();
b.hash = new Buffer('a1a2','hex');
assert.equal(b.hashStr,'a1a2');
b.nextBlockHash = new Buffer('b2b1','hex');
assert.equal(b.nextBlockHashStr,'b2b1');
done();
});
2014-01-08 11:29:39 -08:00
});