Merge bitcoin/bitcoin#32286: test: Handle empty string returned by CLI as None in RPC tests

a4041c77f0 test: Handle empty string returned by CLI as None in RPC tests (Brandon Odiwuor)

Pull request description:

  Partially Fixes https://github.com/bitcoin/bitcoin/issues/32264

  Some tests are failing when `bitcoin-cli` returns an empty string. This change treats an empty response as `None`. See https://github.com/bitcoin/bitcoin/issues/32264#issuecomment-2807616694

  This fixes the error for:
  - feature_bip68_sequence.py
  - feature_nulldummy.py
  - feature_signet.py
  - mining_mainnet.py
  - rpc_scanblocks.py
  - rpc_scantxoutset.py
  - wallet_descriptor.py --descriptors

ACKs for top commit:
  maflcko:
    lgtm ACK a4041c77f0
  achow101:
    ACK a4041c77f0
  pablomartin4btc:
    ACK a4041c77f0
  mzumsande:
    ACK a4041c77f0

Tree-SHA512: 2f1a416a18e0b3eebdb014c2e2e8dadf1d46b15c231cb61f577d47f5e551994ab0e2aeb7c179c01be7c1f07ebc03476236d29cf2d04c358ffb1fae985aa385c9
This commit is contained in:
Ava Chow 2025-04-16 16:17:35 -07:00
commit eb6b1003c1
No known key found for this signature in database
GPG key ID: 17565732E08E5E41

View file

@ -919,6 +919,8 @@ class TestNodeCLI():
# Ignore cli_stdout, raise with cli_stderr
raise subprocess.CalledProcessError(returncode, p_args, output=cli_stderr)
try:
if not cli_stdout.strip():
return None
return json.loads(cli_stdout, parse_float=decimal.Decimal)
except (json.JSONDecodeError, decimal.InvalidOperation):
return cli_stdout.rstrip("\n")