From 33fdfc7986455191df8ce339261bc0561115cf7f Mon Sep 17 00:00:00 2001 From: brunoerg Date: Fri, 14 Oct 2022 12:02:19 -0300 Subject: [PATCH] test: perturb anchors.dat to test it doesn't throw an error during initialization --- test/functional/feature_anchors.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/functional/feature_anchors.py b/test/functional/feature_anchors.py index 713c0826d39..468ad1eafaa 100755 --- a/test/functional/feature_anchors.py +++ b/test/functional/feature_anchors.py @@ -63,17 +63,25 @@ class AnchorsTest(BitcoinTestFramework): self.log.info("Check the addresses in anchors.dat") with open(node_anchors_path, "rb") as file_handler: - anchors = file_handler.read().hex() + anchors = file_handler.read() + anchors_hex = anchors.hex() for port in block_relay_nodes_port: ip_port = ip + port - assert ip_port in anchors + assert ip_port in anchors_hex for port in inbound_nodes_port: ip_port = ip + port - assert ip_port not in anchors + assert ip_port not in anchors_hex - self.log.info("Start node") - self.start_node(0) + self.log.info("Perturb anchors.dat to test it doesn't throw an error during initialization") + with self.nodes[0].assert_debug_log(["0 block-relay-only anchors will be tried for connections."]): + with open(node_anchors_path, "wb") as out_file_handler: + tweaked_contents = bytearray(anchors) + tweaked_contents[20:20] = b'1' + out_file_handler.write(bytes(tweaked_contents)) + + self.log.info("Start node") + self.start_node(0) self.log.info("When node starts, check if anchors.dat doesn't exist anymore") assert not os.path.exists(node_anchors_path)