aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2024-04-27 15:48:15 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-07-02 08:47:24 +0200
commit2342b46c451658a418f8e28e50b2ad0e5abd284d (patch)
tree40366735769fad4af5e317b8c1e9f4c07fd708d4 /test/functional
parentfaf2a6750b2da97a18c48a3acf9c9da2aebe86d0 (diff)
downloadbitcoin-2342b46c451658a418f8e28e50b2ad0e5abd284d.tar.xz
test: Add coverage for getchaintxstats in assumeutxo context
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/feature_assumeutxo.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index ad8ba78a6a..718a86befb 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -33,6 +33,7 @@ from dataclasses import dataclass
from test_framework.messages import tx_from_hex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
+ assert_approx,
assert_equal,
assert_raises_rpc_error,
)
@@ -301,14 +302,28 @@ class AssumeutxoTest(BitcoinTestFramework):
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 one block is equal to the blocks tx count.
+ # If the window tx count is unknown, the value is missing.
+ # The 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_approx(tx_rate, window_tx_count / window_interval, vspan=0.1)
+ else:
+ assert_equal(tx_rate, None)
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.