[tests] Functional tests must explicitly set num_nodes
This commit is contained in:
parent
5448a1471d
commit
7148b74dc3
15 changed files with 31 additions and 7 deletions
|
@ -77,7 +77,9 @@ class ExampleTest(BitcoinTestFramework):
|
|||
# and setup_nodes() methods to customize the test setup as required.
|
||||
|
||||
def set_test_params(self):
|
||||
"""Override any test parameters for your individual test."""
|
||||
"""Override test parameters for your individual test.
|
||||
|
||||
This method must be overridden and num_nodes must be exlicitly set."""
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 3
|
||||
# Use self.extra_args to change command-line arguments for the nodes
|
||||
|
|
|
@ -16,6 +16,7 @@ def get_unspent(listunspent, amount):
|
|||
|
||||
class RawTransactionsTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def setup_network(self, split=False):
|
||||
|
|
|
@ -23,6 +23,9 @@ class LongpollThread(threading.Thread):
|
|||
self.node.getblocktemplate({'longpollid':self.longpollid})
|
||||
|
||||
class GetBlockTemplateLPTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
|
||||
def run_test(self):
|
||||
self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.")
|
||||
self.nodes[0].generate(10)
|
||||
|
|
|
@ -14,6 +14,9 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import assert_equal
|
||||
|
||||
class GetChainTipsTest (BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
|
||||
def run_test (self):
|
||||
tips = self.nodes[0].getchaintips ()
|
||||
assert_equal (len (tips), 1)
|
||||
|
|
|
@ -9,6 +9,7 @@ from test_framework.util import assert_equal
|
|||
|
||||
class ListSinceBlockTest (BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def run_test(self):
|
||||
|
|
|
@ -17,6 +17,7 @@ def txFromHex(hexstring):
|
|||
|
||||
class ListTransactionsTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
self.enable_mocktime()
|
||||
|
||||
def run_test(self):
|
||||
|
|
|
@ -9,6 +9,7 @@ from test_framework.util import *
|
|||
|
||||
class MerkleBlockTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
# Nodes 0/1 are "wallet" nodes, Nodes 2/3 are used for testing
|
||||
self.extra_args = [[], [], [], ["-txindex"]]
|
||||
|
|
|
@ -34,6 +34,7 @@ def get_virtual_size(witness_block):
|
|||
|
||||
class TestNode(NodeConnCB):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 3
|
||||
self.getdataset = set()
|
||||
|
||||
def on_getdata(self, conn, message):
|
||||
|
|
|
@ -42,6 +42,9 @@ from test_framework.netutil import test_ipv6_local
|
|||
RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports
|
||||
|
||||
class ProxyTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
|
||||
def setup_nodes(self):
|
||||
self.have_ipv6 = test_ipv6_local()
|
||||
# Create two proxies on different ports
|
||||
|
|
|
@ -24,6 +24,7 @@ def get_sub_array_from_array(object_array, to_match):
|
|||
|
||||
class ReceivedByTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
self.enable_mocktime()
|
||||
|
||||
def run_test(self):
|
||||
|
|
|
@ -48,11 +48,10 @@ BITCOIND_PROC_WAIT_TIMEOUT = 60
|
|||
class BitcoinTestFramework(object):
|
||||
"""Base class for a bitcoin test script.
|
||||
|
||||
Individual bitcoin test scripts should subclass this class and override the run_test() method.
|
||||
Individual bitcoin test scripts should subclass this class and override the set_test_params() and run_test() methods.
|
||||
|
||||
Individual tests can also override the following methods to customize the test setup:
|
||||
|
||||
- set_test_params()
|
||||
- add_options()
|
||||
- setup_chain()
|
||||
- setup_network()
|
||||
|
@ -64,12 +63,13 @@ class BitcoinTestFramework(object):
|
|||
|
||||
def __init__(self):
|
||||
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = False
|
||||
self.nodes = []
|
||||
self.mocktime = 0
|
||||
self.set_test_params()
|
||||
|
||||
assert hasattr(self, "num_nodes"), "Test must set self.num_nodes in set_test_params()"
|
||||
|
||||
def main(self):
|
||||
"""Main function. This should not be overridden by the subclass test scripts."""
|
||||
|
||||
|
@ -177,8 +177,8 @@ class BitcoinTestFramework(object):
|
|||
|
||||
# Methods to override in subclass test scripts.
|
||||
def set_test_params(self):
|
||||
"""Override this method to change default values for number of nodes, topology, etc"""
|
||||
pass
|
||||
"""Tests must this method to change default values for number of nodes, topology, etc"""
|
||||
raise NotImplementedError
|
||||
|
||||
def add_options(self, parser):
|
||||
"""Override this method to add command-line options to the test"""
|
||||
|
@ -212,7 +212,7 @@ class BitcoinTestFramework(object):
|
|||
self.start_nodes()
|
||||
|
||||
def run_test(self):
|
||||
"""Override this method to define test logic"""
|
||||
"""Tests must override this method to define test logic"""
|
||||
raise NotImplementedError
|
||||
|
||||
# Public helper methods. These can be accessed by the subclass test scripts.
|
||||
|
|
|
@ -8,6 +8,9 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import *
|
||||
|
||||
class TxnMallTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
|
||||
def add_options(self, parser):
|
||||
parser.add_option("--mineblock", dest="mine_block", default=False, action="store_true",
|
||||
help="Test double-spend of 1-confirmed transaction")
|
||||
|
|
|
@ -8,6 +8,8 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import *
|
||||
|
||||
class TxnMallTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
|
||||
def add_options(self, parser):
|
||||
parser.add_option("--mineblock", dest="mine_block", default=False, action="store_true",
|
||||
|
|
|
@ -8,6 +8,7 @@ from test_framework.util import *
|
|||
|
||||
class WalletTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [['-usehd={:d}'.format(i%2==0)] for i in range(4)]
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ from test_framework.util import *
|
|||
|
||||
class WalletBackupTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
# nodes 1, 2,3 are spenders, let's give them a keypool=100
|
||||
self.extra_args = [["-keypool=100"], ["-keypool=100"], ["-keypool=100"], []]
|
||||
|
|
Loading…
Reference in a new issue