|
28 | 28 | CTxOut, |
29 | 29 | from_binary, |
30 | 30 | from_hex, |
| 31 | + hash256, |
31 | 32 | ser_string, |
32 | 33 | ser_uint256, |
33 | 34 | tx_from_hex, |
34 | 35 | ) |
35 | | -from test_framework.p2p import NetworkThread |
| 36 | +from test_framework.p2p import NetworkThread, MAGIC_BYTES |
36 | 37 | from test_framework.psbt import ( |
37 | 38 | PSBT, |
38 | 39 | PSBT_GLOBAL_UNSIGNED_TX, |
|
94 | 95 | "tank": pod.metadata.name, |
95 | 96 | "namespace": pod.metadata.namespace, |
96 | 97 | "chain": pod.metadata.labels["chain"], |
| 98 | + "p2pport": int(pod.metadata.labels["P2PPort"]), |
97 | 99 | "rpc_host": pod.status.pod_ip, |
98 | 100 | "rpc_port": int(pod.metadata.labels["RPCPort"]), |
99 | 101 | "rpc_user": "user", |
@@ -263,6 +265,7 @@ def setup(self): |
263 | 265 | ) |
264 | 266 | node.rpc_connected = True |
265 | 267 | node.init_peers = int(tank["init_peers"]) |
| 268 | + node.p2pport = tank['p2pport'] |
266 | 269 |
|
267 | 270 | self.nodes.append(node) |
268 | 271 | self.tanks[tank["tank"]] = node |
@@ -295,6 +298,23 @@ def setup(self): |
295 | 298 |
|
296 | 299 | self.success = TestStatus.PASSED |
297 | 300 |
|
| 301 | + if len(self.nodes) > 0 and self.nodes[0].chain == "signet": |
| 302 | + # There's no garuntee that any nodes are responsive |
| 303 | + # but we only need one to figure out the network magic bytes |
| 304 | + for node in self.nodes: |
| 305 | + try: |
| 306 | + # Times out after 60 seconds (!) |
| 307 | + template = node.getblocktemplate({"rules": ["segwit", "signet"]}) |
| 308 | + challenge = template["signet_challenge"] |
| 309 | + challenge_bytes = bytes.fromhex(challenge) |
| 310 | + data = len(challenge_bytes).to_bytes() + challenge_bytes |
| 311 | + digest = hash256(data) |
| 312 | + MAGIC_BYTES["signet"] = digest[0:4] |
| 313 | + self.log.info(f"Got signet network magic bytes from {node.tank}: {MAGIC_BYTES['signet'].hex()}") |
| 314 | + break |
| 315 | + except Exception as e: |
| 316 | + self.log.info(f"Failed to get signet network magic bytes from {node.tank}: {e}") |
| 317 | + |
298 | 318 | def parse_args(self): |
299 | 319 | # Only print "outer" args from parent class when using --help |
300 | 320 | help_parser = argparse.ArgumentParser(usage="%(prog)s [options]") |
@@ -482,7 +502,7 @@ def connect_nodes(self, a, b, *, peer_advertises_v2=None, wait_for_connect: bool |
482 | 502 | to_connection = self.nodes[b] |
483 | 503 | from_num_peers = 1 + len(from_connection.getpeerinfo()) |
484 | 504 | to_num_peers = 1 + len(to_connection.getpeerinfo()) |
485 | | - ip_port = self.nodes[b].rpchost + ":18444" |
| 505 | + ip_port = self.nodes[b].rpchost + ":" + self.nodes[b].p2pport |
486 | 506 |
|
487 | 507 | if peer_advertises_v2 is None: |
488 | 508 | peer_advertises_v2 = self.options.v2transport |
|
0 commit comments