@@ -48,11 +48,10 @@ class TestStatus(Enum):
48
48
class BitcoinTestFramework (object ):
49
49
"""Base class for a bitcoin test script.
50
50
51
- Individual bitcoin test scripts should subclass this class and override the run_test() method .
51
+ Individual bitcoin test scripts should subclass this class and override the set_test_params() and run_test() methods .
52
52
53
53
Individual tests can also override the following methods to customize the test setup:
54
54
55
- - set_test_params()
56
55
- add_options()
57
56
- setup_chain()
58
57
- setup_network()
@@ -64,12 +63,13 @@ class BitcoinTestFramework(object):
64
63
65
64
def __init__ (self ):
66
65
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
67
- self .num_nodes = 4
68
66
self .setup_clean_chain = False
69
67
self .nodes = []
70
68
self .mocktime = 0
71
69
self .set_test_params ()
72
70
71
+ assert hasattr (self , "num_nodes" ), "Test must set self.num_nodes in set_test_params()"
72
+
73
73
def main (self ):
74
74
"""Main function. This should not be overridden by the subclass test scripts."""
75
75
@@ -177,8 +177,8 @@ def main(self):
177
177
178
178
# Methods to override in subclass test scripts.
179
179
def set_test_params (self ):
180
- """Override this method to change default values for number of nodes, topology, etc"""
181
- pass
180
+ """Tests must this method to change default values for number of nodes, topology, etc"""
181
+ raise NotImplementedError
182
182
183
183
def add_options (self , parser ):
184
184
"""Override this method to add command-line options to the test"""
@@ -212,7 +212,7 @@ def setup_nodes(self):
212
212
self .start_nodes ()
213
213
214
214
def run_test (self ):
215
- """Override this method to define test logic"""
215
+ """Tests must override this method to define test logic"""
216
216
raise NotImplementedError
217
217
218
218
# Public helper methods. These can be accessed by the subclass test scripts.
0 commit comments