Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Sep 14, 2015
1 parent 005f316 commit f3c3c1f
Showing 1 changed file with 37 additions and 58 deletions.
95 changes: 37 additions & 58 deletions test/index.js
Expand Up @@ -10,8 +10,8 @@ describe('RpcClient', () => {
bitcoind = new RpcClient(bitcoindConfig)
})

it('call getInfo with callback', (done) => {
new Promise((resolve, reject) => {
it('call getInfo with callback', () => {
return new Promise((resolve, reject) => {
bitcoind.getInfo((err, ret) => {
try {
expect(err).to.be.null
Expand All @@ -23,73 +23,52 @@ describe('RpcClient', () => {
}
})
})
.then(done, done)
})

it('call getInfo', (done) => {
Promise.resolve()
.then(async () => {
let ret = await bitcoind.getInfo()
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})
.then(done, done)
it('call getInfo', async () => {
let ret = await bitcoind.getInfo()
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})

it('call getinfo', (done) => {
Promise.resolve()
.then(async () => {
let ret = await bitcoind.getinfo()
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})
.then(done, done)
it('call getinfo', async () => {
let ret = await bitcoind.getinfo()
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})

it('call getinfo in cmd', (done) => {
Promise.resolve()
.then(async () => {
let ret = await bitcoind.cmd('getinfo')
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})
.then(done, done)
it('call getinfo in cmd', async () => {
let ret = await bitcoind.cmd('getinfo')
expect(ret.error).to.be.null
expect(ret.result).to.be.an('Object')
})

it('batch call', (done) => {
Promise.resolve()
.then(async () => {
let ret = await bitcoind.batch([
{method: 'getinfo'},
{method: 'getbestblockhash'}
])
expect(ret).to.be.an('Array').and.to.have.length(2)
expect(ret[0].error).to.be.null
expect(ret[0].result).to.be.an('Object')
expect(ret[1].error).to.be.null
expect(ret[1].result).to.be.a('String').and.to.have.length(64)
})
.then(done, done)
it('batch call', async () => {
let ret = await bitcoind.batch([
{method: 'getinfo'},
{method: 'getbestblockhash'}
])
expect(ret).to.be.an('Array').and.to.have.length(2)
expect(ret[0].error).to.be.null
expect(ret[0].result).to.be.an('Object')
expect(ret[1].error).to.be.null
expect(ret[1].result).to.be.a('String').and.to.have.length(64)
})

it('batch interface', (done) => {
Promise.resolve()
.then(async () => {
let batch = bitcoind.batch()
batch.getinfo()
batch.clear()
batch.getinfo()
batch.getBestBlockHash()
it('batch interface', async () => {
let batch = bitcoind.batch()
batch.getinfo()
batch.clear()
batch.getinfo()
batch.getBestBlockHash()

let ret = await batch.call()
expect(ret).to.be.an('Array')
expect(ret[0].error).to.be.null
expect(ret[0].result).to.be.an('Object')
expect(ret[1].error).to.be.null
expect(ret[1].result).to.be.a('String').and.to.have.length(64)
let ret = await batch.call()
expect(ret).to.be.an('Array')
expect(ret[0].error).to.be.null
expect(ret[0].result).to.be.an('Object')
expect(ret[1].error).to.be.null
expect(ret[1].result).to.be.a('String').and.to.have.length(64)

expect(::batch.getinfo).to.throw(Error)
})
.then(done, done)
expect(::batch.getinfo).to.throw(Error)
})
})

0 comments on commit f3c3c1f

Please sign in to comment.