simple test for block thin model

This commit is contained in:
Matias Alejo Garcia 2014-01-08 16:46:56 -03:00
parent 08f106aa0c
commit 848b485658
1 changed files with 17 additions and 18 deletions

View File

@ -11,31 +11,30 @@ var
config = require('../../config/config'),
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(){
var block_hash = TESTING_BLOCK;
before(function(done) {
mongoose.connect(config.db);
done();
});
after(function(done) {
mongoose.connection.close();
done();
});
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();
});
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();
});
});
});