Skip to content

Commit ea5a50f

Browse files
author
MarcoFalke
committed
Merge #21042: doc, test: Improve setup_clean_chain documentation
590bda7 scripted-diff: Remove setup_clean_chain if default is not changed (Fabian Jahr) 98892f3 doc: Improve setup_clean_chain documentation (Fabian Jahr) Pull request description: The first commit improves documentation on setup_clean_chain which is misunderstood quite frequently. Most importantly it fixes the TestShell docs which are simply incorrect. The second commit removes the instances of `setup_clean_clain` in functional tests where it is not changing the default. This used to be part of #19168 which also sought to rename`setup_clean_chain`. ACKs for top commit: jonatack: ACK 590bda7 Tree-SHA512: a7881186e65d31160b8f84107fb185973b37c6e50f190a85c6e2906a13a7472bb4efa9440bd37fe0a9ac5cd2d1e8559870a7e4380632d9a249eca8980b945f3e
2 parents f1239b7 + 590bda7 commit ea5a50f

18 files changed

+11
-20
lines changed

test/functional/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ don't have test cases for.
6363
- Avoid stop-starting the nodes multiple times during the test if possible. A
6464
stop-start takes several seconds, so doing it several times blows up the
6565
runtime of the test.
66-
- Set the `self.setup_clean_chain` variable in `set_test_params()` to control whether
67-
or not to use the cached data directories. The cached data directories
68-
contain a 200-block pre-mined blockchain and wallets for four nodes. Each node
69-
has 25 mature blocks (25x50=1250 BTC) in its wallet.
66+
- Set the `self.setup_clean_chain` variable in `set_test_params()` to `True` to
67+
initialize an empty blockchain and start from the Genesis block, rather than
68+
load a premined blockchain from cache with the default value of `False`. The
69+
cached data directories contain a 200-block pre-mined blockchain with the
70+
spendable mining rewards being split between four nodes. Each node has 25
71+
mature block subsidies (25x50=1250 BTC) in its wallet. Using them is much more
72+
efficient than mining blocks in your test.
7073
- When calling RPCs with lots of arguments, consider using named keyword
7174
arguments instead of positional arguments to make the intent of the call
7275
clear to readers.

test/functional/example_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def set_test_params(self):
7676
"""Override test parameters for your individual test.
7777
7878
This method must be overridden and num_nodes must be explicitly set."""
79+
# By default every test loads a pre-mined chain of 200 blocks from cache.
80+
# Set setup_clean_chain to True to skip this and start from the Genesis
81+
# block.
7982
self.setup_clean_chain = True
8083
self.num_nodes = 3
8184
# Use self.extra_args to change command-line arguments for the nodes

test/functional/feature_asmap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def expected_messages(filename):
3636

3737
class AsmapTest(BitcoinTestFramework):
3838
def set_test_params(self):
39-
self.setup_clean_chain = False
4039
self.num_nodes = 1
4140

4241
def test_without_asmap_arg(self):

test/functional/feature_dbcrash.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
class ChainstateWriteCrashTest(BitcoinTestFramework):
5050
def set_test_params(self):
5151
self.num_nodes = 4
52-
self.setup_clean_chain = False
5352
self.rpc_timeout = 480
5453
self.supports_cli = False
5554

test/functional/feature_includeconf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
class IncludeConfTest(BitcoinTestFramework):
2222
def set_test_params(self):
23-
self.setup_clean_chain = False
2423
self.num_nodes = 1
2524

2625
def setup_chain(self):

test/functional/p2p_add_connections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def check_node_connections(*, node, num_in, num_out):
1717

1818
class P2PAddConnections(BitcoinTestFramework):
1919
def set_test_params(self):
20-
self.setup_clean_chain = False
2120
self.num_nodes = 2
2221

2322
def setup_network(self):

test/functional/p2p_addr_relay.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def on_addr(self, message):
4646

4747
class AddrTest(BitcoinTestFramework):
4848
def set_test_params(self):
49-
self.setup_clean_chain = False
5049
self.num_nodes = 1
5150

5251
def run_test(self):

test/functional/p2p_blocksonly.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
class P2PBlocksOnly(BitcoinTestFramework):
1717
def set_test_params(self):
18-
self.setup_clean_chain = False
1918
self.num_nodes = 1
2019
self.extra_args = [["-blocksonly"]]
2120

test/functional/p2p_filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def merkleblock_received(self, value):
8181

8282
class FilterTest(BitcoinTestFramework):
8383
def set_test_params(self):
84-
self.setup_clean_chain = False
8584
self.num_nodes = 1
8685
self.extra_args = [[
8786
'-peerbloomfilters',

test/functional/p2p_getaddr_caching.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def addr_received(self):
4141

4242
class AddrTest(BitcoinTestFramework):
4343
def set_test_params(self):
44-
self.setup_clean_chain = False
4544
self.num_nodes = 1
4645

4746
def run_test(self):

0 commit comments

Comments
 (0)