@@ -350,6 +350,31 @@ def run_test(self):
350
350
assert_equal (loaded ['coins_loaded' ], SNAPSHOT_BASE_HEIGHT )
351
351
assert_equal (loaded ['base_height' ], SNAPSHOT_BASE_HEIGHT )
352
352
353
+ self .log .info ("Check that UTXO-querying RPCs operate on snapshot chainstate" )
354
+ snapshot_hash = loaded ['tip_hash' ]
355
+ snapshot_num_coins = loaded ['coins_loaded' ]
356
+ # coinstatsindex might be not caught up yet and is not relevant for this test, so don't use it
357
+ utxo_info = n1 .gettxoutsetinfo (use_index = False )
358
+ assert_equal (utxo_info ['txouts' ], snapshot_num_coins )
359
+ assert_equal (utxo_info ['height' ], SNAPSHOT_BASE_HEIGHT )
360
+ assert_equal (utxo_info ['bestblock' ], snapshot_hash )
361
+
362
+ # find coinbase output at snapshot height on node0 and scan for it on node1,
363
+ # where the block is not available, but the snapshot was loaded successfully
364
+ coinbase_tx = n0 .getblock (snapshot_hash , verbosity = 2 )['tx' ][0 ]
365
+ assert_raises_rpc_error (- 1 , "Block not found on disk" , n1 .getblock , snapshot_hash )
366
+ coinbase_output_descriptor = coinbase_tx ['vout' ][0 ]['scriptPubKey' ]['desc' ]
367
+ scan_result = n1 .scantxoutset ('start' , [coinbase_output_descriptor ])
368
+ assert_equal (scan_result ['success' ], True )
369
+ assert_equal (scan_result ['txouts' ], snapshot_num_coins )
370
+ assert_equal (scan_result ['height' ], SNAPSHOT_BASE_HEIGHT )
371
+ assert_equal (scan_result ['bestblock' ], snapshot_hash )
372
+ scan_utxos = [(coin ['txid' ], coin ['vout' ]) for coin in scan_result ['unspents' ]]
373
+ assert (coinbase_tx ['txid' ], 0 ) in scan_utxos
374
+
375
+ txout_result = n1 .gettxout (coinbase_tx ['txid' ], 0 )
376
+ assert_equal (txout_result ['scriptPubKey' ]['desc' ], coinbase_output_descriptor )
377
+
353
378
def check_tx_counts (final : bool ) -> None :
354
379
"""Check nTx and nChainTx intermediate values right after loading
355
380
the snapshot, and final values after the snapshot is validated."""
0 commit comments