Browse Source

[tests] Functional tests must explicitly set num_nodes

0.16
John Newbery 7 years ago
parent
commit
7148b74dc3
  1. 4
      test/functional/example_test.py
  2. 1
      test/functional/fundrawtransaction.py
  3. 3
      test/functional/getblocktemplate_longpoll.py
  4. 3
      test/functional/getchaintips.py
  5. 1
      test/functional/listsinceblock.py
  6. 1
      test/functional/listtransactions.py
  7. 1
      test/functional/merkle_blocks.py
  8. 1
      test/functional/p2p-segwit.py
  9. 3
      test/functional/proxy_test.py
  10. 1
      test/functional/receivedby.py
  11. 12
      test/functional/test_framework/test_framework.py
  12. 3
      test/functional/txn_clone.py
  13. 2
      test/functional/txn_doublespend.py
  14. 1
      test/functional/wallet.py
  15. 1
      test/functional/walletbackup.py

4
test/functional/example_test.py

@ -77,7 +77,9 @@ class ExampleTest(BitcoinTestFramework): @@ -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

1
test/functional/fundrawtransaction.py

@ -16,6 +16,7 @@ def get_unspent(listunspent, amount): @@ -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):

3
test/functional/getblocktemplate_longpoll.py

@ -23,6 +23,9 @@ class LongpollThread(threading.Thread): @@ -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)

3
test/functional/getchaintips.py

@ -14,6 +14,9 @@ from test_framework.test_framework import BitcoinTestFramework @@ -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)

1
test/functional/listsinceblock.py

@ -9,6 +9,7 @@ from test_framework.util import assert_equal @@ -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):

1
test/functional/listtransactions.py

@ -17,6 +17,7 @@ def txFromHex(hexstring): @@ -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):

1
test/functional/merkle_blocks.py

@ -9,6 +9,7 @@ from test_framework.util import * @@ -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"]]

1
test/functional/p2p-segwit.py

@ -34,6 +34,7 @@ def get_virtual_size(witness_block): @@ -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):

3
test/functional/proxy_test.py

@ -42,6 +42,9 @@ from test_framework.netutil import test_ipv6_local @@ -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

1
test/functional/receivedby.py

@ -24,6 +24,7 @@ def get_sub_array_from_array(object_array, to_match): @@ -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):

12
test/functional/test_framework/test_framework.py

@ -48,11 +48,10 @@ BITCOIND_PROC_WAIT_TIMEOUT = 60 @@ -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): @@ -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): @@ -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): @@ -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.

3
test/functional/txn_clone.py

@ -8,6 +8,9 @@ from test_framework.test_framework import BitcoinTestFramework @@ -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")

2
test/functional/txn_doublespend.py

@ -8,6 +8,8 @@ from test_framework.test_framework import BitcoinTestFramework @@ -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",

1
test/functional/wallet.py

@ -8,6 +8,7 @@ from test_framework.util import * @@ -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)]

1
test/functional/walletbackup.py

@ -38,6 +38,7 @@ from test_framework.util import * @@ -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…
Cancel
Save