Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 0.12 #4

Merged
merged 1 commit into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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