Merge bitcoin/bitcoin#30053: test: added test coverage to loadtxoutset could not open file

ee67bba76c test: added test coverage to loadtxoutset (kevkevin)

Pull request description:

  The functional test coverage did not cover the rpc error of "Couldn't open file..." for loadtxoutset and this test adds coverage for it

  This adds coverage to this line
  https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L2777

ACKs for top commit:
  maflcko:
    ACK ee67bba76c
  davidgumberg:
    LGTM ACK ee67bba76c
  rkrux:
    ACK [ee67bba](ee67bba76c)
  alfonsoromanz:
    ACK ee67bba76c. Code looks good to me. I also ran `test/functional/feature_assumeutxo.py` to make sure all tests passes, including this one.
  tdb3:
    ACK for ee67bba76c

Tree-SHA512: 210a7eb928f625d2a8d9acb63ee83cb4aaec9c267e5a0c52ad219c2935466e2cdc68667e30ad29566e6060981587e5bec42805d296f6e60f9b3b13f3330575f2
This commit is contained in:
merge-script 2024-05-08 16:15:00 +08:00
commit 43a66c55ec
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -155,6 +155,12 @@ class AssumeutxoTest(BitcoinTestFramework):
self.restart_node(2, extra_args=self.extra_args[2])
def test_invalid_file_path(self):
self.log.info("Test bitcoind should fail when file path is invalid.")
node = self.nodes[0]
path = node.datadir_path / node.chain / "invalid" / "path"
assert_raises_rpc_error(-8, "Couldn't open file {} for reading.".format(path), node.loadtxoutset, path)
def run_test(self):
"""
Bring up two (disconnected) nodes, mine some new blocks on the first,
@ -239,6 +245,7 @@ class AssumeutxoTest(BitcoinTestFramework):
self.test_invalid_mempool_state(dump_output['path'])
self.test_invalid_snapshot_scenarios(dump_output['path'])
self.test_invalid_chainstate_scenarios()
self.test_invalid_file_path()
self.log.info(f"Loading snapshot into second node from {dump_output['path']}")
loaded = n1.loadtxoutset(dump_output['path'])