use standardjs formatting
This commit is contained in:
parent
09d8e440de
commit
399803affa
41 changed files with 1252 additions and 1177 deletions
test
|
@ -1,13 +1,15 @@
|
|||
/* global describe, it, beforeEach */
|
||||
|
||||
var assert = require('assert')
|
||||
|
||||
var Block = require('../src/block')
|
||||
|
||||
var fixtures = require('./fixtures/block')
|
||||
|
||||
describe('Block', function() {
|
||||
describe('fromBuffer/fromHex', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('imports the block: ' + f.description + ' correctly', function() {
|
||||
describe('Block', function () {
|
||||
describe('fromBuffer/fromHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports the block: ' + f.description + ' correctly', function () {
|
||||
var block = Block.fromHex(f.hex)
|
||||
|
||||
assert.equal(block.version, f.version)
|
||||
|
@ -19,66 +21,66 @@ describe('Block', function() {
|
|||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.forEach(function(f) {
|
||||
it('throws on ' + f.exception, function() {
|
||||
assert.throws(function() {
|
||||
fixtures.invalid.forEach(function (f) {
|
||||
it('throws on ' + f.exception, function () {
|
||||
assert.throws(function () {
|
||||
Block.fromHex(f.hex)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('toBuffer/toHex', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
describe('toBuffer/toHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
var block
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
block = Block.fromHex(f.hex)
|
||||
})
|
||||
|
||||
it('exports the block: ' + f.description + ' correctly', function() {
|
||||
it('exports the block: ' + f.description + ' correctly', function () {
|
||||
assert.equal(block.toHex(), f.hex)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getHash', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
describe('getHash', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
var block
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
block = Block.fromHex(f.hex)
|
||||
})
|
||||
|
||||
it('calculates ' + f.hash + ' for the block: ' + f.description, function() {
|
||||
it('calculates ' + f.hash + ' for the block: ' + f.description, function () {
|
||||
assert.equal(block.getHash().toString('hex'), f.hash)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getId', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
describe('getId', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
var block
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
block = Block.fromHex(f.hex)
|
||||
})
|
||||
|
||||
it('calculates ' + f.id + ' for the block: ' + f.description, function() {
|
||||
it('calculates ' + f.id + ' for the block: ' + f.description, function () {
|
||||
assert.equal(block.getId(), f.id)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getUTCDate', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
describe('getUTCDate', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
var block
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
block = Block.fromHex(f.hex)
|
||||
})
|
||||
|
||||
it('returns UTC date of ' + f.id, function() {
|
||||
it('returns UTC date of ' + f.id, function () {
|
||||
var utcDate = block.getUTCDate().getTime()
|
||||
|
||||
assert.equal(utcDate, f.timestamp * 1e3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue