|
33 | 33 | from test_framework.messages import tx_from_hex
|
34 | 34 | from test_framework.test_framework import BitcoinTestFramework
|
35 | 35 | from test_framework.util import (
|
| 36 | + assert_approx, |
36 | 37 | assert_equal,
|
37 | 38 | assert_raises_rpc_error,
|
38 | 39 | )
|
@@ -301,14 +302,28 @@ def check_tx_counts(final: bool) -> None:
|
301 | 302 | the snapshot, and final values after the snapshot is validated."""
|
302 | 303 | for height, block in blocks.items():
|
303 | 304 | tx = n1.getblockheader(block.hash)["nTx"]
|
304 |
| - chain_tx = n1.getchaintxstats(nblocks=1, blockhash=block.hash).get("txcount", None) |
| 305 | + stats = n1.getchaintxstats(nblocks=1, blockhash=block.hash) |
| 306 | + chain_tx = stats.get("txcount", None) |
| 307 | + window_tx_count = stats.get("window_tx_count", None) |
| 308 | + tx_rate = stats.get("txrate", None) |
| 309 | + window_interval = stats.get("window_interval") |
305 | 310 |
|
306 | 311 | # Intermediate nTx of the starting block should be set, but nTx of
|
307 | 312 | # later blocks should be 0 before they are downloaded.
|
| 313 | + # The window_tx_count of one block is equal to the blocks tx count. |
| 314 | + # If the window tx count is unknown, the value is missing. |
| 315 | + # The tx_rate is calculated from window_tx_count and window_interval |
| 316 | + # when possible. |
308 | 317 | if final or height == START_HEIGHT:
|
309 | 318 | assert_equal(tx, block.tx)
|
| 319 | + assert_equal(window_tx_count, tx) |
| 320 | + if window_interval > 0: |
| 321 | + assert_approx(tx_rate, window_tx_count / window_interval, vspan=0.1) |
| 322 | + else: |
| 323 | + assert_equal(tx_rate, None) |
310 | 324 | else:
|
311 | 325 | assert_equal(tx, 0)
|
| 326 | + assert_equal(window_tx_count, None) |
312 | 327 |
|
313 | 328 | # Intermediate nChainTx of the starting block and snapshot block
|
314 | 329 | # should be set, but others should be None until they are downloaded.
|
|
0 commit comments