diff --git a/app/models/Status.js b/app/models/Status.js index 283032b..2ddffc4 100644 --- a/app/models/Status.js +++ b/app/models/Status.js @@ -10,16 +10,33 @@ function spec() { function Status() { this.info = {}; + this.difficulty = {}; } Status.prototype.getInfo = function(next) { var that = this; async.series([ function (cb) { - rpc.getInfo(function(err, block){ + rpc.getInfo(function(err, info){ if (err) return cb(err); - that.info = block.result; + that.info = info.result; + return cb(); + }); + } + ], function (err) { + return next(err); + }); + }; + + Status.prototype.getDifficulty = function(next) { + var that = this; + async.series([ + function (cb) { + rpc.getDifficulty(function(err, df){ + if (err) return cb(err); + + that.difficulty = df.result; return cb(); }); } diff --git a/test/model/status.js b/test/model/status.js index 0bcd6cd..e1c22bc 100644 --- a/test/model/status.js +++ b/test/model/status.js @@ -25,7 +25,17 @@ describe('Status', function(){ d.getInfo(function(err) { if (err) done(err); - assert.equal(4096, d.info.difficulty); + assert.equal('number', typeof d.info.difficulty); + done(); + }); + }); + + it('getDifficulty', function(done) { + var d = new Status(); + + d.getDifficulty(function(err) { + if (err) done(err); + assert.equal('number', typeof d.difficulty); done(); }); });