test: Use extra_port() helper in feature_bind_extra.py

This commit is contained in:
MarcoFalke 2025-08-27 09:44:29 +02:00
parent 6ca6f3b37b
commit fabc2615af
No known key found for this signature in database
1 changed files with 12 additions and 8 deletions

View File

@ -37,37 +37,41 @@ class BindExtraTest(BitcoinTestFramework):
loopback_ipv4 = addr_to_hex("127.0.0.1")
# Start custom ports by reusing unused p2p ports
port = p2p_port(self.num_nodes)
def extra_port():
port = p2p_port(extra_port.index)
extra_port.index += 1
return port
extra_port.index = self.num_nodes
# Array of tuples [command line arguments, expected bind addresses].
self.expected = []
# Node0, no normal -bind=... with -bind=...=onion, thus only the tor target.
port = extra_port()
self.expected.append(
[
[f"-bind=127.0.0.1:{port}=onion"],
[(loopback_ipv4, port)]
[(loopback_ipv4, port)],
],
)
port += 1
# Node1, both -bind=... and -bind=...=onion.
port = [extra_port(), extra_port()]
self.expected.append(
[
[f"-bind=127.0.0.1:{port}", f"-bind=127.0.0.1:{port + 1}=onion"],
[(loopback_ipv4, port), (loopback_ipv4, port + 1)]
[f"-bind=127.0.0.1:{port[0]}", f"-bind=127.0.0.1:{port[1]}=onion"],
[(loopback_ipv4, port[0]), (loopback_ipv4, port[1])],
],
)
port += 2
# Node2, no -bind=...=onion, thus no extra port for Tor target.
port = extra_port()
self.expected.append(
[
[f"-bind=127.0.0.1:{port}"],
[(loopback_ipv4, port)]
[(loopback_ipv4, port)],
],
)
port += 1
self.extra_args = list(map(lambda e: e[0], self.expected))
self.setup_nodes()