Skip to content

Commit 11fcda7

Browse files
committed
Add support for 0.12
1 parent b43a766 commit 11fcda7

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
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

+10-11
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

@@ -375,7 +374,7 @@ describe('Client', () => {
375374
it('should return a transaction json-encoded by default', () => {
376375
return client.listUnspent()
377376
.then(([transaction]) => client.getTransactionByHash(transaction.txid))
378-
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'time', 'txid', 'version', 'vin', 'vout'));
377+
.then((transaction) => transaction.should.have.keys('blockhash', 'blocktime', 'confirmations', 'locktime', 'size', 'time', 'txid', 'version', 'vin', 'vout'));
379378
});
380379
});
381380

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

401400
it('should return a block summary json-encoded if `summary` is enabled', () => {
402401
return client.getBlockByHash('0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', { extension: 'json', summary: true })
403402
.then((block) => {
404-
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
403+
block.should.have.keys('bits', 'chainwork', 'confirmations', 'difficulty', 'hash', 'height', 'mediantime', 'merkleroot', 'nextblockhash', 'nonce', 'size', 'time', 'tx', 'version');
405404
block.tx.should.matchEach((value) => value.should.be.a.String());
406405
});
407406
});
@@ -473,14 +472,14 @@ describe('Client', () => {
473472
describe('getMemoryPoolContent()', () => {
474473
it('should return memory pool content json-encoded by default', () => {
475474
return new Client(config.bitcoind).getMemoryPoolContent()
476-
.then((content) => content.should.equal('Not Found'));
475+
.then((content) => content.should.eql({}));
477476
});
478477
});
479478

480479
describe('getMemoryPoolInformation()', () => {
481480
it('should return memory pool information json-encoded by default', () => {
482481
return new Client(config.bitcoind).getMemoryPoolContent()
483-
.then((information) => information.should.equal('Not Found'));
482+
.then((information) => information.should.eql({}));
484483
});
485484
});
486485
});

0 commit comments

Comments
 (0)