Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show All 9 Lines | |||||
import logging | import logging | ||||
import os | import os | ||||
import pdb | import pdb | ||||
import random | import random | ||||
import shutil | import shutil | ||||
import sys | import sys | ||||
import tempfile | import tempfile | ||||
import time | import time | ||||
from typing import Optional | |||||
from .authproxy import JSONRPCException | from .authproxy import JSONRPCException | ||||
from . import coverage | from . import coverage | ||||
from .test_node import TestNode | from .test_node import TestNode | ||||
from .mininode import NetworkThread | from .mininode import NetworkThread | ||||
from .util import ( | from .util import ( | ||||
assert_equal, | assert_equal, | ||||
check_json_precision, | check_json_precision, | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): | ||||
- setup_chain() | - setup_chain() | ||||
- setup_network() | - setup_network() | ||||
- setup_nodes() | - setup_nodes() | ||||
The __init__() and main() methods should not be overridden. | The __init__() and main() methods should not be overridden. | ||||
This class also contains various public and private helper methods.""" | This class also contains various public and private helper methods.""" | ||||
chain: Optional[str] = None | |||||
setup_clean_chain: Optional[bool] = None | |||||
def __init__(self): | def __init__(self): | ||||
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method""" | """Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method""" | ||||
self.chain = 'regtest' | self.chain = 'regtest' | ||||
self.setup_clean_chain = False | self.setup_clean_chain = False | ||||
self.nodes = [] | self.nodes = [] | ||||
self.network_thread = None | self.network_thread = None | ||||
# Wait for up to 60 seconds for the RPC server to respond | # Wait for up to 60 seconds for the RPC server to respond | ||||
self.rpc_timeout = 60 | self.rpc_timeout = 60 | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): | ||||
def run_test(self): | def run_test(self): | ||||
"""Tests must override this method to define test logic""" | """Tests must override this method to define test logic""" | ||||
raise NotImplementedError | raise NotImplementedError | ||||
# Public helper methods. These can be accessed by the subclass test | # Public helper methods. These can be accessed by the subclass test | ||||
# scripts. | # scripts. | ||||
def add_nodes(self, num_nodes, extra_args=None, | def add_nodes(self, num_nodes: int, extra_args=None, | ||||
*, host=None, binary=None): | *, host=None, binary=None): | ||||
"""Instantiate TestNode objects. | """Instantiate TestNode objects. | ||||
Should only be called once after the nodes have been specified in | Should only be called once after the nodes have been specified in | ||||
set_test_params().""" | set_test_params().""" | ||||
if self.bind_to_localhost_only: | if self.bind_to_localhost_only: | ||||
extra_confs = [["bind=127.0.0.1"]] * num_nodes | extra_confs = [["bind=127.0.0.1"]] * num_nodes | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |