1
0
mirror of https://github.com/Bytom/bytom-node-sdk.git synced 2020-06-03 17:14:54 +00:00
bytom-node-sdk/test/block.js
2018-11-23 16:36:27 +08:00

87 lines
2.1 KiB
JavaScript

/* eslint-env mocha */
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised)
const expect = chai.expect
const {
client
} = require('./testHelpers')
describe('Block', () => {
describe('block count', () => {
it('simple example', () =>
client.block.getBlockCount()
.then(items =>
expect(items.block_count).not.to.be.empty
)
)
})
describe('block hash', () => {
it('simple example', () => {
return client.block.getBlockHash()
.then((resp) => {
expect(resp.block_hash).not.to.be.empty
})
})
})
describe('get Block', () => {
it('simple example', () => {
let blockHash
return client.block.getBlockHash()
.then((resp) => {
blockHash = resp.block_hash
return client.block.getBlock({block_hash: resp.block_hash})
})
.then((resp) =>
expect(resp.hash).to.equal(blockHash)
)
})
})
describe('get Block Header', () => {
it('simple example', () => {
let blockHash
return client.block.getBlockHash()
.then((resp) => {
blockHash = resp.block_hash
return client.block.getBlockHeader({block_hash: resp.block_hash})
})
.then((resp) =>
expect(resp.block_header).not.to.be.empty
)
})
})
describe('get Difficulty', () => {
it('simple example', () => {
let blockHash
return client.block.getBlockHash()
.then((resp) => {
blockHash = resp.block_hash
return client.block.getDifficulty({block_hash: resp.block_hash})
})
.then((resp) =>
expect(resp.hash).to.equal(blockHash)
)
})
})
describe('get Hash Rate', () => {
it('simple example', () => {
let blockHash
return client.block.getBlockHash()
.then((resp) => {
blockHash = resp.block_hash
return client.block.getHashRate({block_hash: resp.block_hash})
})
.then((resp) =>
expect(resp.hash).to.equal(blockHash)
)
})
})
})