fixed calcDifficulty by making sure the MAX_TARGET is also locally available.
added tests for 2 difficulty calculations.
This commit is contained in:
parent
1b69051708
commit
9c6c300289
|
@ -187,4 +187,17 @@ describe('util', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('#calcDifficulty', function() {
|
||||||
|
var bitsgenesis = 486604799;
|
||||||
|
it('should work for ' + bitsgenesis, function() {
|
||||||
|
var difficulty = coinUtil.calcDifficulty(bitsgenesis);
|
||||||
|
difficulty.should.equal(1);
|
||||||
|
});
|
||||||
|
var bitslater = 419476394;
|
||||||
|
it('should work for ' + bitslater, function() {
|
||||||
|
var difficulty = coinUtil.calcDifficulty(bitslater);
|
||||||
|
difficulty.should.equal(6119726089);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -510,4 +510,4 @@ exports.INT64_MAX = INT64_MAX;
|
||||||
// makes 1 BTC
|
// makes 1 BTC
|
||||||
exports.COIN = 100000000;
|
exports.COIN = 100000000;
|
||||||
|
|
||||||
exports.MAX_TARGET = new Buffer('00000000FFFF0000000000000000000000000000000000000000000000000000', 'hex');
|
var MAX_TARGET = exports.MAX_TARGET = new Buffer('00000000FFFF0000000000000000000000000000000000000000000000000000', 'hex');
|
||||||
|
|
Loading…
Reference in New Issue