[tests] Demostration/concept: Add a TestNode class to test_Framework.py #10082
This PR is too large for review and will need continually rebasing. This PR tracks the individual tasks to introduce a TestNode class. The individual commits are in separate PRs
This PR adds a TestNode class to the test_framework.py module. The goals for this are:
The test writer should be able to set up a desired network topology and not have to think too hard about how to start bitcoind instances and setup RPC/P2P connections to them.
To create a node with an RPC and a P2P connection, tests currently look something like this:
self.nodes =  self.nodes.append(start_node(0, self.options.tmpdir)) node0 = SingleNodeConnCB() connections =  connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes, node0)) node0.add_connection(connections) NetworkThread().start() # Start up network handling in another thread node0.wait_for_verack()
After this PR, that should be more like this:
self.num_nodes = 1 self.start_nodes() self.nodes.add_p2p_connection()
the tester now has a TestNode instance
There are currently several global state variables in utils.py (COVERAGE_DIR, PortSeed and bitcoind_processes). Having global state variables in the utils module is bad practice and makes importing from utils quite brittle. It also makes it difficult to add functionality to the test framework without inadvertently breaking something.