-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
index: Coinstats index can be activated with command line flag
Summary: This is a backport of [[bitcoin/bitcoin#19521 | core#19521]] [5/17] bitcoin/bitcoin@3c914d5 partial bitcoin/bitcoin@6a4c0c0 The functional test only checks that "-coinstatsindex" argument does not break anything. The rest of the functional test from commit 6a4c0c09ab is not yet applicable and will be added in the next commit. This includes also minor documentation fixups from [[ bitcoin/bitcoin#21818 | core#21818]] Depends on D11598 and D11595 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11599
- Loading branch information
Showing
9 changed files
with
143 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2020 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
"""Test coinstatsindex across nodes. | ||
Test that the values returned by gettxoutsetinfo are consistent | ||
between a node running the coinstatsindex and a node without | ||
the index. | ||
""" | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import assert_equal, try_rpc | ||
|
||
|
||
class CoinStatsIndexTest(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.setup_clean_chain = True | ||
self.num_nodes = 2 | ||
self.supports_cli = False | ||
self.extra_args = [ | ||
[], | ||
["-coinstatsindex"] | ||
] | ||
|
||
def skip_test_if_missing_module(self): | ||
self.skip_if_no_wallet() | ||
|
||
def run_test(self): | ||
self._test_coin_stats_index() | ||
|
||
def _test_coin_stats_index(self): | ||
node = self.nodes[0] | ||
index_node = self.nodes[1] | ||
# Both none and muhash options allow the usage of the index | ||
index_hash_options = ['none', 'muhash'] | ||
|
||
# Generate a normal transaction and mine it | ||
node.generate(101) | ||
address = self.nodes[0].get_deterministic_priv_key().address | ||
node.sendtoaddress( | ||
address=address, | ||
amount=10_000_000, | ||
subtractfeefromamount=True) | ||
node.generate(1) | ||
|
||
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 work on the index, so | ||
# don't check them. | ||
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) | ||
res1.pop('muhash', None) | ||
|
||
# The fields 'disk_size' and 'transactions' do not work on the index | ||
# so don't check them (they will be removed from the index in the | ||
# next commit). | ||
del res1['disk_size'], res1['transactions'] | ||
|
||
# Everything left should be the same | ||
assert_equal(res1, res0) | ||
|
||
|
||
if __name__ == '__main__': | ||
CoinStatsIndexTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters