chaintope / bitcoinrb

The implementation of the bitcoin protocol for ruby.
MIT License
61 stars 19 forks source link

Fix `Bitcoin::RPC::BitcoinCoreClient` raises unexpected error. #51

Closed Takeshi-Y closed 4 years ago

Takeshi-Y commented 4 years ago

Bitcoin::RPC::BitcoinCoreClient raise TypeError when server respond with error messages, but expected to RuntimeError. This pull-request is fix this.

@client = Bitcoin::RPC::BitcoinCoreClient.new(config)

# before
@client.getblock("INVALID_BLOCK_HASH")
> TypeError (exception class/object expected)

# after
@client.getblock("INVALID_BLOCK_HASH")
> RuntimeError ({"code"=>-8, "message"=>"blockhash must be of length 64 (not 18, for 'INVALID_BLOCK_HASH')"})

Add WebMock gem for stubbing http-request in test.

azuchi commented 4 years ago

Thanks!