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

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-01-08 11:29:39 -08:00
#!/usr/bin/env node
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var TESTING_BLOCK = '000000000185678d3d7ecc9962c96418174431f93fe20bf216d5565272423f74';
2014-01-08 11:29:39 -08:00
var
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) {
2014-01-08 11:46:56 -08:00
var block2 = Block.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
if (err) done(err);
2014-01-08 11:29:39 -08:00
2014-01-08 11:46:56 -08:00
assert.equal(b2.hash, 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) {
var block2 = Block.fromHashWithInfo(TESTING_BLOCK, function(err, b2) {
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
});
});
});