aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-10-10 19:38:59 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-10-11 11:58:07 +0200
commit3bb51c29df596aab2c1fde184667cee435597715 (patch)
treec940611061acc9795337950b606f60475ecaaba3 /test
parent04265ba9378efbd4c35b33390b1e5cf246d420a9 (diff)
test: BIP324: add check for missing garbage terminator detection
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_v2_transport.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/functional/p2p_v2_transport.py b/test/functional/p2p_v2_transport.py
index dd564fed88..99417a17a9 100755
--- a/test/functional/p2p_v2_transport.py
+++ b/test/functional/p2p_v2_transport.py
@@ -148,6 +148,19 @@ class V2TransportTest(BitcoinTestFramework):
with self.nodes[0].assert_debug_log("V2 transport error: V1 peer with wrong MessageStart"):
s.sendall(wrong_network_magic_prefix + b"somepayload")
+ # Check detection of missing garbage terminator (hits after fixed amount of data if terminator never matches garbage)
+ MAX_KEY_GARB_AND_GARBTERM_LEN = 64 + 4095 + 16
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+ num_peers = len(self.nodes[0].getpeerinfo())
+ s.connect(("127.0.0.1", p2p_port(0)))
+ self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == num_peers + 1)
+ s.sendall(b'\x00' * (MAX_KEY_GARB_AND_GARBTERM_LEN - 1))
+ self.wait_until(lambda: self.nodes[0].getpeerinfo()[-1]["bytesrecv"] == MAX_KEY_GARB_AND_GARBTERM_LEN - 1)
+ with self.nodes[0].assert_debug_log("V2 transport error: missing garbage terminator"):
+ s.sendall(b'\x00') # send out last byte
+ # should disconnect immediately
+ self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == num_peers)
+
if __name__ == '__main__':
V2TransportTest().main()