rust-bitcoin / rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
340 stars 255 forks source link

Allow warnings to be either a string or a string sequence. #353

Closed arik-so closed 6 months ago

arik-so commented 6 months ago

In recent versions of bitcoind, getblockchaininfo returns a result whose warnings key is no longer a string, but an array of strings. This PR allows the parsing of either. Fixes #352.

tcharding commented 6 months ago

Thanks for the fix! I'm going to ack this on the assumption that you tested it because you ran into the problem.

FTR the PR can't be tested because we are so far behind :(

ACK 87c95f6bda73453f12b28ae712e0e396b5401aed

arik-so commented 6 months ago

Thanks so much!

As a matter of fact, I did test it, but to do so, I also added a test module to main.rs and separately ran a local server that returned different values for the warning key based on a switch I could flip. Would it perhaps be helpful to add some unit tests besides the integration tests that could rely on a mock server?

tcharding commented 6 months ago

Legend! You could add some tests if you like but I wouldn't bother putting too much effort in because the whole crate is in need of love.

0xB10C commented 6 months ago

fwiw: this was merged into Bitcoin Core master 2 days ago https://github.com/bitcoin/bitcoin/pull/29845

But I don't think it hurts having this in here early.

arik-so commented 6 months ago

This is wild! My colleague ran into an issue with electrs because of that just yesterday, so must have been particularly unlucky with the timing of cloning bitcoind.