Skip to content

Commit

Permalink
Add support for 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ruimarinho committed Feb 19, 2016
1 parent b43a766 commit 441c4b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sut:
- bitcoind-username-only

bitcoind:
image: seegno/bitcoind:0.11
image: seegno/bitcoind:0.12
command:
-datadir=/var/lib/bitcoind
-printtoconsole
Expand Down
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import RpcError from './errors/rpc-error';
*/

function get(body, { headers = false, response } = {}) {
if (!body) {
throw new RpcError(response.statusCode, response.statusMessage);
}

if (body.error !== null) {
throw new RpcError(
_.get(body, 'error.code', -32603),
Expand Down
24 changes: 11 additions & 13 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ describe('Client', () => {
return new Client(_.defaults({ headers: true }, config.bitcoind)).getInfo()
.then(([info, headers]) => {
info.should.be.an.Object();
headers.should.have.property('server');
headers.server.should.startWith('bitcoin-json-rpc');

headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
});
});

Expand All @@ -132,8 +132,8 @@ describe('Client', () => {
should.not.exist(err);

info.should.be.an.Object();
headers.should.have.property('server');
headers.server.should.startWith('bitcoin-json-rpc');

headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
});
});

Expand All @@ -146,8 +146,7 @@ describe('Client', () => {
.then(([addresses, headers]) => {
addresses.should.have.length(batch.length);

headers.should.have.property('server');
headers.server.should.startWith('bitcoin-json-rpc');
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
});
});

Expand All @@ -161,8 +160,7 @@ describe('Client', () => {

addresses.should.have.length(batch.length);

headers.should.have.property('server');
headers.server.should.startWith('bitcoin-json-rpc');
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
});
});
});
Expand Down Expand Up @@ -375,7 +373,7 @@ describe('Client', () => {
it('should return a transaction json-encoded by default', () => {
return client.listUnspent()
.then(([transaction]) => client.getTransactionByHash(transaction.txid))
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'time', 'txid', 'version', 'vin', 'vout'));
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'size', 'time', 'txid', 'version', 'vin', 'vout'));
});
});

Expand All @@ -393,15 +391,15 @@ describe('Client', () => {
it('should return a block json-encoded by default', () => {
return client.getBlockByHash('0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', { extension: 'json' })
.then((block) => {
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'mediantime', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
block.tx.should.matchEach((value) => value.should.be.an.Object());
});
});

it('should return a block summary json-encoded if `summary` is enabled', () => {
return client.getBlockByHash('0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', { extension: 'json', summary: true })
.then((block) => {
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'mediantime', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
block.tx.should.matchEach((value) => value.should.be.a.String());
});
});
Expand Down Expand Up @@ -473,14 +471,14 @@ describe('Client', () => {
describe('getMemoryPoolContent()', () => {
it('should return memory pool content json-encoded by default', () => {
return new Client(config.bitcoind).getMemoryPoolContent()
.then((content) => content.should.equal('Not Found'));
.then((content) => content.should.eql({}));
});
});

describe('getMemoryPoolInformation()', () => {
it('should return memory pool information json-encoded by default', () => {
return new Client(config.bitcoind).getMemoryPoolContent()
.then((information) => information.should.equal('Not Found'));
.then((information) => information.should.eql({}));
});
});
});
Expand Down

0 comments on commit 441c4b9

Please sign in to comment.