Browse Source

Merge pull request #226 from blocktrail/calcDifficulty-fix

fixed util.calcDifficulty
patch-2
Ryan X. Charles 11 years ago
parent
commit
290c8af140
  1. 13
      test/test.util.js
  2. 2
      util/util.js

13
test/test.util.js

@ -187,4 +187,17 @@ describe('util', function() {
});
});
});
describe('#calcDifficulty', function() {
var bitsgenesis = 486604799;
it('should work for the bits from the genesis block; ' + bitsgenesis, function() {
var difficulty = coinUtil.calcDifficulty(bitsgenesis);
difficulty.should.equal(1);
});
var randomotherbits = 419476394;
it('should work for the bits in a randomly chosen block, eg [00000000000000001fef2bbc6da9b65e16f9187b7d88f15a308490bf2c9b8e1d] ' + randomotherbits, function() {
var difficulty = coinUtil.calcDifficulty(randomotherbits);
difficulty.should.equal(6119726089);
});
});
});

2
util/util.js

@ -510,4 +510,4 @@ exports.INT64_MAX = INT64_MAX;
// makes 1 BTC
exports.COIN = 100000000;
exports.MAX_TARGET = new Buffer('00000000FFFF0000000000000000000000000000000000000000000000000000', 'hex');
var MAX_TARGET = exports.MAX_TARGET = new Buffer('00000000FFFF0000000000000000000000000000000000000000000000000000', 'hex');

Loading…
Cancel
Save