Skip to content

Commit

Permalink
test: Add coverage for getchaintxstats in assumeutxo context
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Apr 27, 2024
1 parent fa28613 commit 03a0f31
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,26 @@ def check_tx_counts(final: bool) -> None:
the snapshot, and final values after the snapshot is validated."""
for height, block in blocks.items():
tx = n1.getblockheader(block.hash)["nTx"]
chain_tx = n1.getchaintxstats(nblocks=1, blockhash=block.hash).get("txcount", None)
stats = n1.getchaintxstats(nblocks=1, blockhash=block.hash)
chain_tx = stats.get("txcount", None)
window_tx_count = stats.get("window_tx_count", None)
tx_rate = stats.get("txrate", None)
window_interval = stats.get("window_interval")

# Intermediate nTx of the starting block should be set, but nTx of
# later blocks should be 0 before they are downloaded.
# The window_tx_count of 1 block is equal to the blocks tx count.
# If the tx count would be 0 the value is missing.
# If tx_rate is calculated from window_tx_count and window_interval
# when possible.
if final or height == START_HEIGHT:
assert_equal(tx, block.tx)
assert_equal(window_tx_count, tx)
if window_interval > 0:
assert_equal(tx_rate, window_tx_count/window_interval)
else:
assert_equal(tx, 0)
assert_equal(window_tx_count, None)

# Intermediate nChainTx of the starting block and snapshot block
# should be set, but others should be None until they are downloaded.
Expand Down

0 comments on commit 03a0f31

Please sign in to comment.