@@ -94,6 +94,7 @@ def oversized_addr_test(self):
94
94
self .nodes [0 ].disconnect_p2ps ()
95
95
96
96
def relay_tests (self ):
97
+ self .log .info ('Test address relay' )
97
98
self .log .info ('Check that addr message content is relayed and added to addrman' )
98
99
addr_source = self .nodes [0 ].add_p2p_connection (P2PInterface ())
99
100
num_receivers = 7
@@ -122,6 +123,35 @@ def relay_tests(self):
122
123
123
124
self .nodes [0 ].disconnect_p2ps ()
124
125
126
+ self .log .info ('Check relay of addresses received from outbound peers' )
127
+ inbound_peer = self .nodes [0 ].add_p2p_connection (AddrReceiver ())
128
+ full_outbound_peer = self .nodes [0 ].add_outbound_p2p_connection (GetAddrStore (), p2p_idx = 0 , connection_type = "outbound-full-relay" )
129
+ msg = self .setup_addr_msg (2 )
130
+ self .send_addr_msg (full_outbound_peer , msg , [inbound_peer ])
131
+ self .log .info ('Check that the first addr message received from an outbound peer is not relayed' )
132
+ # Currently, there is a flag that prevents the first addr message received
133
+ # from a new outbound peer to be relayed to others. Originally meant to prevent
134
+ # large GETADDR responses from being relayed, it now typically affects the self-announcement
135
+ # of the outbound peer which is often sent before the GETADDR response.
136
+ assert_equal (inbound_peer .num_ipv4_received , 0 )
137
+
138
+ self .log .info ('Check that subsequent addr messages sent from an outbound peer are relayed' )
139
+ msg2 = self .setup_addr_msg (2 )
140
+ self .send_addr_msg (full_outbound_peer , msg2 , [inbound_peer ])
141
+ assert_equal (inbound_peer .num_ipv4_received , 2 )
142
+
143
+ self .log .info ('Check address relay to outbound peers' )
144
+ block_relay_peer = self .nodes [0 ].add_outbound_p2p_connection (GetAddrStore (), p2p_idx = 1 , connection_type = "block-relay-only" )
145
+ msg3 = self .setup_addr_msg (2 )
146
+ self .send_addr_msg (inbound_peer , msg3 , [full_outbound_peer , block_relay_peer ])
147
+
148
+ self .log .info ('Check that addresses are relayed to full outbound peers' )
149
+ assert_equal (full_outbound_peer .num_ipv4_received , 2 )
150
+ self .log .info ('Check that addresses are not relayed to block-relay-only outbound peers' )
151
+ assert_equal (block_relay_peer .num_ipv4_received , 0 )
152
+
153
+ self .nodes [0 ].disconnect_p2ps ()
154
+
125
155
def getaddr_tests (self ):
126
156
self .log .info ('Test getaddr behavior' )
127
157
self .log .info ('Check that we send a getaddr message upon connecting to an outbound-full-relay peer' )
0 commit comments