Merge bitcoin/bitcoin#32145: test: Add functional test for bitcoin-chainstate

ca55613fd1 test: Add functional test for bitcoin-chainstate (TheCharlatan)
3f9c716e7f test: Fix docstring for cmake migration (TheCharlatan)

Pull request description:

  While the `bitcoin-chainstate` utility is not shipped in a release, it is the only current utility directly using the bitcoin kernel library. Adding a simple test for it is useful for checking that the library is actually usable. The test is also useful in future to demonstrate that the `bitcoin-chainstate` binary using the API for the kernel library introduced in #30595 actually works and offers similar features.

ACKs for top commit:
  laanwj:
    Code review ACK ca55613fd1
  maflcko:
    ACK ca55613fd1 🎭
  kevkevinpal:
    ACK ca55613fd1

Tree-SHA512: 282627f5fac868a84aab9962ef2cbd3a8d3941d9f9dc2a3f26db1e7706ffa8051637ab5f8372676800e426e077ca40449a9e3e42a003048472339d81ed81bca8
This commit is contained in:
Ryan Ofsky
2025-03-27 10:33:15 -04:00
5 changed files with 67 additions and 1 deletions

View File

@@ -88,6 +88,10 @@ class Binaries:
"Return argv array that should be used to invoke bitcoin-wallet"
return self._argv(self.paths.bitcoinwallet)
def chainstate_argv(self):
"Return argv array that should be used to invoke bitcoin-chainstate"
return self._argv(self.paths.bitcoinchainstate)
def _argv(self, bin_path):
"""Return argv array that should be used to invoke the command.
Normally this will return binary paths directly from the paths object,
@@ -291,6 +295,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"bitcoind": ("bitcoind", "BITCOIND"),
"bitcoin-cli": ("bitcoincli", "BITCOINCLI"),
"bitcoin-util": ("bitcoinutil", "BITCOINUTIL"),
"bitcoin-chainstate": ("bitcoinchainstate", "BITCOINCHAINSTATE"),
"bitcoin-wallet": ("bitcoinwallet", "BITCOINWALLET"),
}
for binary, [attribute_name, env_variable_name] in binaries.items():
@@ -1022,6 +1027,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if not self.is_bitcoin_util_compiled():
raise SkipTest("bitcoin-util has not been compiled")
def skip_if_no_bitcoin_chainstate(self):
"""Skip the running test if bitcoin-chainstate has not been compiled."""
if not self.is_bitcoin_chainstate_compiled():
raise SkipTest("bitcoin-chainstate has not been compiled")
def skip_if_no_cli(self):
"""Skip the running test if bitcoin-cli has not been compiled."""
if not self.is_cli_compiled():
@@ -1073,6 +1083,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"""Checks whether bitcoin-util was compiled."""
return self.config["components"].getboolean("ENABLE_BITCOIN_UTIL")
def is_bitcoin_chainstate_compiled(self):
"""Checks whether bitcoin-chainstate was compiled."""
return self.config["components"].getboolean("ENABLE_BITCOIN_CHAINSTATE")
def is_zmq_compiled(self):
"""Checks whether the zmq module was compiled."""
return self.config["components"].getboolean("ENABLE_ZMQ")