simple test for block thin model
This commit is contained in:
parent
08f106aa0c
commit
848b485658
|
@ -11,31 +11,30 @@ var
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
Block = require('../../app/models/Block');
|
Block = require('../../app/models/Block');
|
||||||
|
|
||||||
mongoose.connect(config.db);
|
|
||||||
|
|
||||||
var db = mongoose.connection;
|
mongoose.connection.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
describe('getInfo', function(){
|
describe('getInfo', function(){
|
||||||
|
|
||||||
var block_hash = TESTING_BLOCK;
|
before(function(done) {
|
||||||
|
mongoose.connect(config.db);
|
||||||
|
|
||||||
db.on('error', console.error.bind(console, 'connection error:'));
|
|
||||||
|
|
||||||
db.once('open', function (){
|
|
||||||
|
|
||||||
|
|
||||||
var block2 = Block.fromHashWithInfo(block_hash, function(err, b2) {
|
|
||||||
if (err) done(err);
|
|
||||||
|
|
||||||
console.log("Block obj:");
|
|
||||||
console.log(b2);
|
|
||||||
console.log("Block.info:");
|
|
||||||
console.log(b2.info);
|
|
||||||
db.close();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
mongoose.connection.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pool block\'s info from bitcoind', function(done) {
|
||||||
|
var block2 = Block.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, '00000000000000000000000000000000000000000000000000446af21d50acd3');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue