mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
Merge bitcoin/bitcoin#22047: index, rpc: Coinstatsindex follow-ups
779e638ca9
coinstats: Add comments for new coinstatsindex values (Fabian Jahr)5b3d4e724f
Index: Improve logging in coinstatsindex (Fabian Jahr)d4356d4e48
rpc: Block until synced if coinstatsindex is used in gettxoutsetinfo (Fabian Jahr)a5f6791139
rpc: Add missing gettxoutsetinfo help docs (Fabian Jahr)01386bfd88
Index: Return early from failed coinstatsindex init (Fabian Jahr)1e3842385b
index: Use batch writing in coinstatsindex WriteBlock (Fabian Jahr)fb65dde147
scripted-diff: Fix coinstats data member names (Fabian Jahr)8ea8c927ac
index: Avoid unnecessary type casts in coinstatsindex (Fabian Jahr) Pull request description: This is a collection of smaller follow-ups to #19521, addressing several post-merge review comments. ACKs for top commit: Sjors: re-utACK779e638ca9
jonatack: re-ACK779e638ca9
diff since last review involves doc changes only; rebased to current master and verified clean debug build/no silent conflicts, unit tests, and feature_coinstatsindex functional test laanwj: Code review ACK779e638ca9
Talkless: re-utACK779e638ca9
after cosmetic changes. Tree-SHA512: cb0d038d230c582d7fe3041c89b1e04d39971fab3739d540c609cf826754c6c513b12ded08ac92180aec7a9d7a70114ece50357bd1a902de4adaae9f30b8d699
This commit is contained in:
@ -32,7 +32,6 @@ from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
try_rpc,
|
||||
)
|
||||
|
||||
class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
@ -76,13 +75,11 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
self.sync_blocks(timeout=120)
|
||||
|
||||
self.log.info("Test that gettxoutsetinfo() output is consistent with or without coinstatsindex option")
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", node.gettxoutsetinfo))
|
||||
res0 = node.gettxoutsetinfo('none')
|
||||
|
||||
# The fields 'disk_size' and 'transactions' do not exist on the index
|
||||
del res0['disk_size'], res0['transactions']
|
||||
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
for hash_option in index_hash_options:
|
||||
res1 = index_node.gettxoutsetinfo(hash_option)
|
||||
# The fields 'block_info' and 'total_unspendable_amount' only exist on the index
|
||||
@ -97,7 +94,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
# Generate a new tip
|
||||
node.generate(5)
|
||||
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
for hash_option in index_hash_options:
|
||||
# Fetch old stats by height
|
||||
res2 = index_node.gettxoutsetinfo(hash_option, 102)
|
||||
@ -176,7 +172,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
for hash_option in index_hash_options:
|
||||
# Check all amounts were registered correctly
|
||||
res6 = index_node.gettxoutsetinfo(hash_option, 108)
|
||||
@ -209,7 +204,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
self.nodes[0].submitblock(block.serialize().hex())
|
||||
self.sync_all()
|
||||
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
for hash_option in index_hash_options:
|
||||
res7 = index_node.gettxoutsetinfo(hash_option, 109)
|
||||
assert_equal(res7['total_unspendable_amount'], Decimal('80.98999999'))
|
||||
@ -235,7 +229,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
assert_equal(res8, res9)
|
||||
|
||||
index_node.generate(1)
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
res10 = index_node.gettxoutsetinfo('muhash')
|
||||
assert(res8['txouts'] < res10['txouts'])
|
||||
|
||||
@ -256,14 +249,12 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
index_node = self.nodes[1]
|
||||
reorg_blocks = index_node.generatetoaddress(2, index_node.getnewaddress())
|
||||
reorg_block = reorg_blocks[1]
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
res_invalid = index_node.gettxoutsetinfo('muhash')
|
||||
index_node.invalidateblock(reorg_blocks[0])
|
||||
assert_equal(index_node.gettxoutsetinfo('muhash')['height'], 110)
|
||||
|
||||
# Add two new blocks
|
||||
block = index_node.generate(2)[1]
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
res = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=False)
|
||||
|
||||
# Test that the result of the reorged block is not returned for its old block height
|
||||
@ -285,9 +276,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
# Ensure that removing and re-adding blocks yields consistent results
|
||||
block = index_node.getblockhash(99)
|
||||
index_node.invalidateblock(block)
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
index_node.reconsiderblock(block)
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
res3 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=112)
|
||||
assert_equal(res2, res3)
|
||||
|
||||
@ -297,8 +286,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
node.getblock(reorg_block)
|
||||
|
||||
self.restart_node(0, ["-coinstatsindex"])
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash'))
|
||||
assert_raises_rpc_error(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash', reorg_block)
|
||||
assert_raises_rpc_error(-32603, "Unable to get data because coinstatsindex is still syncing.", node.gettxoutsetinfo, 'muhash', reorg_block)
|
||||
|
||||
def _test_index_rejects_hash_serialized(self):
|
||||
self.log.info("Test that the rpc raises if the legacy hash is passed with the index")
|
||||
|
Reference in New Issue
Block a user