File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,19 @@ def run_test(self):
148148 with self .nodes [0 ].assert_debug_log ("V2 transport error: V1 peer with wrong MessageStart" ):
149149 s .sendall (wrong_network_magic_prefix + b"somepayload" )
150150
151+ # Check detection of missing garbage terminator (hits after fixed amount of data if terminator never matches garbage)
152+ MAX_KEY_GARB_AND_GARBTERM_LEN = 64 + 4095 + 16
153+ with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
154+ num_peers = len (self .nodes [0 ].getpeerinfo ())
155+ s .connect (("127.0.0.1" , p2p_port (0 )))
156+ self .wait_until (lambda : len (self .nodes [0 ].getpeerinfo ()) == num_peers + 1 )
157+ s .sendall (b'\x00 ' * (MAX_KEY_GARB_AND_GARBTERM_LEN - 1 ))
158+ self .wait_until (lambda : self .nodes [0 ].getpeerinfo ()[- 1 ]["bytesrecv" ] == MAX_KEY_GARB_AND_GARBTERM_LEN - 1 )
159+ with self .nodes [0 ].assert_debug_log ("V2 transport error: missing garbage terminator" ):
160+ s .sendall (b'\x00 ' ) # send out last byte
161+ # should disconnect immediately
162+ self .wait_until (lambda : len (self .nodes [0 ].getpeerinfo ()) == num_peers )
163+
151164
152165if __name__ == '__main__' :
153166 V2TransportTest ().main ()
You can’t perform that action at this time.
0 commit comments