add Block.calculateTarget, use Buffer comparison rather than bigi
This commit is contained in:
parent
26ccb43047
commit
86b51b2d62
4 changed files with 45 additions and 10 deletions
test
|
@ -1,12 +1,21 @@
|
|||
/* global describe, it, beforeEach */
|
||||
|
||||
var assert = require('assert')
|
||||
|
||||
var Block = require('../src/block')
|
||||
|
||||
var fixtures = require('./fixtures/block')
|
||||
|
||||
describe('Block', function () {
|
||||
describe('calculateTarget', function () {
|
||||
fixtures.targets.forEach(function (f) {
|
||||
it('returns ' + f.expected + ' for 0x' + f.bits, function () {
|
||||
var bits = parseInt(f.bits, 16)
|
||||
|
||||
assert.equal(Block.calculateTarget(bits).toString('hex'), f.expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fromBuffer/fromHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports the block: ' + f.description + ' correctly', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue