Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | def _initialize_chain_clean(self): | ||||
"""Initialize empty blockchain for use by the test. | """Initialize empty blockchain for use by the test. | ||||
Create an empty blockchain and num_nodes wallets. | Create an empty blockchain and num_nodes wallets. | ||||
Useful if a test case wants complete control over initialization.""" | Useful if a test case wants complete control over initialization.""" | ||||
for i in range(self.num_nodes): | for i in range(self.num_nodes): | ||||
initialize_datadir(self.options.tmpdir, i) | initialize_datadir(self.options.tmpdir, i) | ||||
class ComparisonTestFramework(BitcoinTestFramework): | |||||
"""Test framework for doing p2p comparison testing | |||||
Sets up some bitcoind binaries: | |||||
- 1 binary: test binary | |||||
- 2 binaries: 1 test binary, 1 ref binary | |||||
- n>2 binaries: 1 test binary, n-1 ref binaries""" | |||||
def set_test_params(self): | |||||
self.num_nodes = 2 | |||||
self.setup_clean_chain = True | |||||
def add_options(self, parser): | |||||
parser.add_argument("--testbinary", dest="testbinary", | |||||
help="bitcoind binary to test") | |||||
parser.add_argument("--refbinary", dest="refbinary", | |||||
help="bitcoind binary to use for reference nodes (if any)") | |||||
def setup_network(self): | |||||
extra_args = [['-whitelist=127.0.0.1']] * self.num_nodes | |||||
if not self.options.testbinary: | |||||
self.options.testbinary = self.options.bitcoind | |||||
if not self.options.refbinary: | |||||
self.options.refbinary = self.options.bitcoind | |||||
if hasattr(self, "extra_args"): | |||||
extra_args = self.extra_args | |||||
self.add_nodes(self.num_nodes, extra_args, | |||||
binary=[self.options.testbinary] + | |||||
[self.options.refbinary] * (self.num_nodes - 1)) | |||||
self.start_nodes() | |||||
class SkipTest(Exception): | class SkipTest(Exception): | ||||
"""This exception is raised to skip a test""" | """This exception is raised to skip a test""" | ||||
def __init__(self, message): | def __init__(self, message): | ||||
self.message = message | self.message = message |