aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-08-21 13:30:00 -0400
committerAva Chow <github@achow101.com>2024-08-21 13:30:00 -0400
commitbc87ad98543299e1990ee1994d0653df3ac70093 (patch)
tree886113589776c05ac548ec0ef186fecd497b719d
parent60b816439eb4bd837778d424628cd3978e0856d9 (diff)
parent917e70a6206c62c4c492fa922425fc8e00d3f328 (diff)
Merge bitcoin/bitcoin#30636: test: assumeutxo: check that UTXO-querying RPCs operate on snapshot chainstate
917e70a6206c62c4c492fa922425fc8e00d3f328 test: assumeutxo: check that UTXO-querying RPCs operate on snapshot chainstate (Sebastian Falbesoner) Pull request description: Inspired by some manual testing I did for #28553, this PR checks that RPCs which explicitly query the UTXO set database (i.e. `gettxoutsetinfo`, `scantxoutset` and `gettxout`) operate on the snapshot chainstate as expected. ACKs for top commit: fjahr: utACK 917e70a6206c62c4c492fa922425fc8e00d3f328 achow101: ACK 917e70a6206c62c4c492fa922425fc8e00d3f328 tdb3: ACK 917e70a6206c62c4c492fa922425fc8e00d3f328 Tree-SHA512: 40ecd1c5dd879234df1667fa5444a1fbbee9b7c456f597dc982d1a2bce46fe9107711b005ab829e570ef919a4914792f72f342d71d92bad2ae9434b5e68d5bd3
-rwxr-xr-xtest/functional/feature_assumeutxo.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index fd6a9518e8..a212704311 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -350,6 +350,31 @@ class AssumeutxoTest(BitcoinTestFramework):
assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)
+ self.log.info("Check that UTXO-querying RPCs operate on snapshot chainstate")
+ snapshot_hash = loaded['tip_hash']
+ snapshot_num_coins = loaded['coins_loaded']
+ # coinstatsindex might be not caught up yet and is not relevant for this test, so don't use it
+ utxo_info = n1.gettxoutsetinfo(use_index=False)
+ assert_equal(utxo_info['txouts'], snapshot_num_coins)
+ assert_equal(utxo_info['height'], SNAPSHOT_BASE_HEIGHT)
+ assert_equal(utxo_info['bestblock'], snapshot_hash)
+
+ # find coinbase output at snapshot height on node0 and scan for it on node1,
+ # where the block is not available, but the snapshot was loaded successfully
+ coinbase_tx = n0.getblock(snapshot_hash, verbosity=2)['tx'][0]
+ assert_raises_rpc_error(-1, "Block not found on disk", n1.getblock, snapshot_hash)
+ coinbase_output_descriptor = coinbase_tx['vout'][0]['scriptPubKey']['desc']
+ scan_result = n1.scantxoutset('start', [coinbase_output_descriptor])
+ assert_equal(scan_result['success'], True)
+ assert_equal(scan_result['txouts'], snapshot_num_coins)
+ assert_equal(scan_result['height'], SNAPSHOT_BASE_HEIGHT)
+ assert_equal(scan_result['bestblock'], snapshot_hash)
+ scan_utxos = [(coin['txid'], coin['vout']) for coin in scan_result['unspents']]
+ assert (coinbase_tx['txid'], 0) in scan_utxos
+
+ txout_result = n1.gettxout(coinbase_tx['txid'], 0)
+ assert_equal(txout_result['scriptPubKey']['desc'], coinbase_output_descriptor)
+
def check_tx_counts(final: bool) -> None:
"""Check nTx and nChainTx intermediate values right after loading
the snapshot, and final values after the snapshot is validated."""