tests/block: check that block.transactions exists and cleanup

This commit is contained in:
Daniel Cousens 2017-04-18 11:52:11 +10:00 committed by Daniel Cousens
parent b552c63fb0
commit e205b99180

View file

@ -27,7 +27,7 @@ describe('Block', function () {
describe('fromBuffer/fromHex', function () {
fixtures.valid.forEach(function (f) {
it('imports the block: ' + f.description + ' correctly', function () {
it('imports ' + f.description, function () {
var block = Block.fromHex(f.hex)
assert.strictEqual(block.version, f.version)
@ -36,6 +36,7 @@ describe('Block', function () {
assert.strictEqual(block.timestamp, f.timestamp)
assert.strictEqual(block.bits, f.bits)
assert.strictEqual(block.nonce, f.nonce)
assert.strictEqual(!block.transactions, f.hex.length === 160)
})
})
@ -56,13 +57,13 @@ describe('Block', function () {
block = Block.fromHex(f.hex)
})
it('exports the block: ' + f.description + ' correctly', function () {
it('exports ' + f.description, function () {
assert.strictEqual(block.toHex(), f.hex)
})
})
})
describe('getHash', function () {
describe('getHash/getId', function () {
fixtures.valid.forEach(function (f) {
var block
@ -70,21 +71,8 @@ describe('Block', function () {
block = Block.fromHex(f.hex)
})
it('returns ' + f.hash + ' for the block: ' + f.description, function () {
it('returns ' + f.id + ' for ' + f.description, function () {
assert.strictEqual(block.getHash().toString('hex'), f.hash)
})
})
})
describe('getId', function () {
fixtures.valid.forEach(function (f) {
var block
beforeEach(function () {
block = Block.fromHex(f.hex)
})
it('returns ' + f.id + ' for the block: ' + f.description, function () {
assert.strictEqual(block.getId(), f.id)
})
})