aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-08-24 11:11:56 -0400
committerMarcoFalke <falke.marco@gmail.com>2017-10-03 18:44:16 +0200
commit82bf6fc6d48a232cc0ceb54b136d86914f49013c (patch)
treed9709ea3cb26287e192aed77e65ca17cfb9c9a39 /test
parent801d2ae9247be5870344c8b4ed5c372ab8930408 (diff)
downloadbitcoin-82bf6fc6d48a232cc0ceb54b136d86914f49013c.tar.xz
[tests] Functional tests must explicitly set num_nodes
Github-Pull: #11121 Rebased-From: 7148b74dc39110f53c665b94fa9d994c6ad6dc1c
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/example_test.py4
-rwxr-xr-xtest/functional/fundrawtransaction.py1
-rwxr-xr-xtest/functional/getblocktemplate_longpoll.py3
-rwxr-xr-xtest/functional/getchaintips.py3
-rwxr-xr-xtest/functional/listsinceblock.py1
-rwxr-xr-xtest/functional/listtransactions.py1
-rwxr-xr-xtest/functional/merkle_blocks.py1
-rwxr-xr-xtest/functional/p2p-segwit.py1
-rwxr-xr-xtest/functional/proxy_test.py3
-rwxr-xr-xtest/functional/receivedby.py1
-rwxr-xr-xtest/functional/test_framework/test_framework.py12
-rwxr-xr-xtest/functional/txn_clone.py3
-rwxr-xr-xtest/functional/txn_doublespend.py2
-rwxr-xr-xtest/functional/wallet.py1
-rwxr-xr-xtest/functional/walletbackup.py1
15 files changed, 31 insertions, 7 deletions
diff --git a/test/functional/example_test.py b/test/functional/example_test.py
index de8934f74b..936aceb89a 100755
--- a/test/functional/example_test.py
+++ b/test/functional/example_test.py
@@ -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
diff --git a/test/functional/fundrawtransaction.py b/test/functional/fundrawtransaction.py
index dec3d41bfc..3326b58c45 100755
--- a/test/functional/fundrawtransaction.py
+++ b/test/functional/fundrawtransaction.py
@@ -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):
diff --git a/test/functional/getblocktemplate_longpoll.py b/test/functional/getblocktemplate_longpoll.py
index 85d2560244..89768bd2fb 100755
--- a/test/functional/getblocktemplate_longpoll.py
+++ b/test/functional/getblocktemplate_longpoll.py
@@ -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)
diff --git a/test/functional/getchaintips.py b/test/functional/getchaintips.py
index 00fc23c6b0..21b67bfc64 100755
--- a/test/functional/getchaintips.py
+++ b/test/functional/getchaintips.py
@@ -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)
diff --git a/test/functional/listsinceblock.py b/test/functional/listsinceblock.py
index ed1315e805..6f428388ec 100755
--- a/test/functional/listsinceblock.py
+++ b/test/functional/listsinceblock.py
@@ -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):
diff --git a/test/functional/listtransactions.py b/test/functional/listtransactions.py
index 5ee85a0dac..e4522cc3b5 100755
--- a/test/functional/listtransactions.py
+++ b/test/functional/listtransactions.py
@@ -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):
diff --git a/test/functional/merkle_blocks.py b/test/functional/merkle_blocks.py
index 2125c6e17b..a58334b2a5 100755
--- a/test/functional/merkle_blocks.py
+++ b/test/functional/merkle_blocks.py
@@ -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"]]
diff --git a/test/functional/p2p-segwit.py b/test/functional/p2p-segwit.py
index 8c2d2f0272..9bb72c8199 100755
--- a/test/functional/p2p-segwit.py
+++ b/test/functional/p2p-segwit.py
@@ -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):
diff --git a/test/functional/proxy_test.py b/test/functional/proxy_test.py
index 26cb645da4..81b99d1bf4 100755
--- a/test/functional/proxy_test.py
+++ b/test/functional/proxy_test.py
@@ -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
diff --git a/test/functional/receivedby.py b/test/functional/receivedby.py
index 48eb1c51b5..db6fc86b82 100755
--- a/test/functional/receivedby.py
+++ b/test/functional/receivedby.py
@@ -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):
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index d860bc5594..103651f175 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -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.
diff --git a/test/functional/txn_clone.py b/test/functional/txn_clone.py
index fc133050b0..740bb2d4c5 100755
--- a/test/functional/txn_clone.py
+++ b/test/functional/txn_clone.py
@@ -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")
diff --git a/test/functional/txn_doublespend.py b/test/functional/txn_doublespend.py
index ff24fac254..69629ef951 100755
--- a/test/functional/txn_doublespend.py
+++ b/test/functional/txn_doublespend.py
@@ -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",
diff --git a/test/functional/wallet.py b/test/functional/wallet.py
index 79727f9be6..de3aa8a875 100755
--- a/test/functional/wallet.py
+++ b/test/functional/wallet.py
@@ -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)]
diff --git a/test/functional/walletbackup.py b/test/functional/walletbackup.py
index 36714164a8..15ea26afa1 100755
--- a/test/functional/walletbackup.py
+++ b/test/functional/walletbackup.py
@@ -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"], []]