MCPcopy Create free account
hub / github.com/ElementsProject/elements / setup_network

Method setup_network

test/functional/feature_bind_extra.py:35–74  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

33 self.num_nodes = 2
34
35 def setup_network(self):
36 # Override setup_network() because we want to put the result of
37 # p2p_port() in self.extra_args[], before the nodes are started.
38 # p2p_port() is not usable in set_test_params() because PortSeed.n is
39 # not set at that time.
40
41 # Due to OS-specific network stats queries, we only run on Linux.
42 self.log.info("Checking for Linux")
43 if not sys.platform.startswith('linux'):
44 raise SkipTest("This test can only be run on Linux.")
45
46 loopback_ipv4 = addr_to_hex("127.0.0.1")
47
48 # Start custom ports after p2p and rpc ports.
49 port = PORT_MIN + 2 * PORT_RANGE
50
51 # Array of tuples [command line arguments, expected bind addresses].
52 self.expected = []
53
54 # Node0, no normal -bind=... with -bind=...=onion, thus only the tor target.
55 self.expected.append(
56 [
57 [f"-bind=127.0.0.1:{port}=onion"],
58 [(loopback_ipv4, port)]
59 ],
60 )
61 port += 1
62
63 # Node1, both -bind=... and -bind=...=onion.
64 self.expected.append(
65 [
66 [f"-bind=127.0.0.1:{port}", f"-bind=127.0.0.1:{port + 1}=onion"],
67 [(loopback_ipv4, port), (loopback_ipv4, port + 1)]
68 ],
69 )
70 port += 2
71
72 self.extra_args = list(map(lambda e: e[0], self.expected))
73 self.add_nodes(self.num_nodes, self.extra_args)
74 # Don't start the nodes, as some of them would collide trying to bind on the same port.
75
76 def run_test(self):
77 for i in range(len(self.expected)):

Callers

nothing calls this directly

Calls 4

SkipTestClass · 0.90
addr_to_hexFunction · 0.90
infoMethod · 0.80
add_nodesMethod · 0.45

Tested by

no test coverage detected