Skip to content

Commit 191f5c0

Browse files
committed
Merge pull request #4 from seegno/enhancement/add-support-for-0-12
Add support for 0.12
2 parents b43a766 + 441c4b9 commit 191f5c0

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sut:
88
- bitcoind-username-only
99

1010
bitcoind:
11-
image: seegno/bitcoind:0.11
11+
image: seegno/bitcoind:0.12
1212
command:
1313
-datadir=/var/lib/bitcoind
1414
-printtoconsole

src/parser.js

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import RpcError from './errors/rpc-error';
1111
*/
1212

1313
function get(body, { headers = false, response } = {}) {
14+
if (!body) {
15+
throw new RpcError(response.statusCode, response.statusMessage);
16+
}
17+
1418
if (body.error !== null) {
1519
throw new RpcError(
1620
_.get(body, 'error.code', -32603),

test/index_test.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ describe('Client', () => {
122122
return new Client(_.defaults({ headers: true }, config.bitcoind)).getInfo()
123123
.then(([info, headers]) => {
124124
info.should.be.an.Object();
125-
headers.should.have.property('server');
126-
headers.server.should.startWith('bitcoin-json-rpc');
125+
126+
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
127127
});
128128
});
129129

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

134134
info.should.be.an.Object();
135-
headers.should.have.property('server');
136-
headers.server.should.startWith('bitcoin-json-rpc');
135+
136+
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
137137
});
138138
});
139139

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

149-
headers.should.have.property('server');
150-
headers.server.should.startWith('bitcoin-json-rpc');
149+
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
151150
});
152151
});
153152

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

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

164-
headers.should.have.property('server');
165-
headers.server.should.startWith('bitcoin-json-rpc');
163+
headers.should.have.keys('date', 'connection', 'content-length', 'content-type');
166164
});
167165
});
168166
});
@@ -375,7 +373,7 @@ describe('Client', () => {
375373
it('should return a transaction json-encoded by default', () => {
376374
return client.listUnspent()
377375
.then(([transaction]) => client.getTransactionByHash(transaction.txid))
378-
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'time', 'txid', 'version', 'vin', 'vout'));
376+
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'size', 'time', 'txid', 'version', 'vin', 'vout'));
379377
});
380378
});
381379

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

401399
it('should return a block summary json-encoded if `summary` is enabled', () => {
402400
return client.getBlockByHash('0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', { extension: 'json', summary: true })
403401
.then((block) => {
404-
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
402+
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'mediantime', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
405403
block.tx.should.matchEach((value) => value.should.be.a.String());
406404
});
407405
});
@@ -473,14 +471,14 @@ describe('Client', () => {
473471
describe('getMemoryPoolContent()', () => {
474472
it('should return memory pool content json-encoded by default', () => {
475473
return new Client(config.bitcoind).getMemoryPoolContent()
476-
.then((content) => content.should.equal('Not Found'));
474+
.then((content) => content.should.eql({}));
477475
});
478476
});
479477

480478
describe('getMemoryPoolInformation()', () => {
481479
it('should return memory pool information json-encoded by default', () => {
482480
return new Client(config.bitcoind).getMemoryPoolContent()
483-
.then((information) => information.should.equal('Not Found'));
481+
.then((information) => information.should.eql({}));
484482
});
485483
});
486484
});

0 commit comments

Comments
 (0)