@@ -31,17 +31,17 @@ fn test_add_addr() {
3131 let mut peer_store: PeerStore = Default :: default ( ) ;
3232 assert_eq ! (
3333 peer_store
34- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
34+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
3535 . len( ) ,
3636 0
3737 ) ;
3838 let addr = random_addr ( ) ;
3939 peer_store. add_addr ( addr, Flags :: COMPATIBILITY ) . unwrap ( ) ;
40- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 1 ) ;
40+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 1 ) ;
4141 // we have not connected yet, so return 0
4242 assert_eq ! (
4343 peer_store
44- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
44+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
4545 . len( ) ,
4646 0
4747 ) ;
@@ -141,14 +141,14 @@ fn test_attempt_ban() {
141141
142142 assert_eq ! (
143143 peer_store
144- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
144+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
145145 . len( ) ,
146146 1
147147 ) ;
148148 peer_store. ban_addr ( & addr, 10_000 , "no reason" . into ( ) ) ;
149149 assert_eq ! (
150150 peer_store
151- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
151+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
152152 . len( ) ,
153153 0
154154 ) ;
@@ -161,7 +161,7 @@ fn test_fetch_addrs_to_attempt() {
161161
162162 let mut peer_store: PeerStore = Default :: default ( ) ;
163163 assert ! ( peer_store
164- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
164+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
165165 . is_empty( ) ) ;
166166 let addr = random_addr ( ) ;
167167 peer_store
@@ -176,13 +176,13 @@ fn test_fetch_addrs_to_attempt() {
176176
177177 assert_eq ! (
178178 peer_store
179- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
179+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
180180 . len( ) ,
181181 1
182182 ) ;
183183 peer_store. add_connected_peer ( addr, SessionType :: Outbound ) ;
184184 assert ! ( peer_store
185- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
185+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
186186 . is_empty( ) ) ;
187187}
188188
@@ -199,18 +199,18 @@ fn test_fetch_addrs_to_attempt_or_feeler() {
199199
200200 assert_eq ! (
201201 peer_store
202- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
202+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
203203 . len( ) ,
204204 1
205205 ) ;
206- assert ! ( peer_store. fetch_addrs_to_feeler( 2 ) . is_empty( ) ) ;
206+ assert ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . is_empty( ) ) ;
207207
208208 _faketime_guard. set_faketime ( 100_000 + ADDR_TRY_TIMEOUT_MS + 1 ) ;
209209
210210 assert ! ( peer_store
211- . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY )
211+ . fetch_addrs_to_attempt( 2 , Flags :: COMPATIBILITY , |_| true )
212212 . is_empty( ) ) ;
213- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 1 ) ;
213+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 1 ) ;
214214}
215215
216216#[ test]
@@ -229,14 +229,14 @@ fn test_fetch_addrs_to_attempt_in_last_minutes() {
229229 paddr. mark_tried ( now) ;
230230 }
231231 assert ! ( peer_store
232- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
232+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
233233 . is_empty( ) ) ;
234234 // after 60 seconds
235235 if let Some ( paddr) = peer_store. mut_addr_manager ( ) . get_mut ( & addr) {
236236 paddr. mark_tried ( now - 60_001 ) ;
237237 }
238238 assert ! ( peer_store
239- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
239+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
240240 . is_empty( ) ) ;
241241 peer_store
242242 . mut_addr_manager ( )
@@ -247,7 +247,7 @@ fn test_fetch_addrs_to_attempt_in_last_minutes() {
247247
248248 assert_eq ! (
249249 peer_store
250- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
250+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
251251 . len( ) ,
252252 1
253253 ) ;
@@ -256,7 +256,7 @@ fn test_fetch_addrs_to_attempt_in_last_minutes() {
256256 }
257257 assert_eq ! (
258258 peer_store
259- . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY )
259+ . fetch_addrs_to_attempt( 1 , Flags :: COMPATIBILITY , |_| true )
260260 . len( ) ,
261261 1
262262 ) ;
@@ -265,18 +265,18 @@ fn test_fetch_addrs_to_attempt_in_last_minutes() {
265265#[ test]
266266fn test_fetch_addrs_to_feeler ( ) {
267267 let mut peer_store: PeerStore = Default :: default ( ) ;
268- assert ! ( peer_store. fetch_addrs_to_feeler( 1 ) . is_empty( ) ) ;
268+ assert ! ( peer_store. fetch_addrs_to_feeler( 1 , |_| true ) . is_empty( ) ) ;
269269 let addr = random_addr ( ) ;
270270
271271 // add an addr
272272 peer_store
273273 . add_addr ( addr. clone ( ) , Flags :: COMPATIBILITY )
274274 . unwrap ( ) ;
275- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 1 ) ;
275+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 1 ) ;
276276
277277 // ignores connected peers' addrs
278278 peer_store. add_connected_peer ( addr. clone ( ) , SessionType :: Outbound ) ;
279- assert ! ( peer_store. fetch_addrs_to_feeler( 1 ) . is_empty( ) ) ;
279+ assert ! ( peer_store. fetch_addrs_to_feeler( 1 , |_| true ) . is_empty( ) ) ;
280280
281281 // peer does not need feeler if it connected to us recently
282282 peer_store
@@ -285,7 +285,7 @@ fn test_fetch_addrs_to_feeler() {
285285 . unwrap ( )
286286 . last_connected_at_ms = ckb_systemtime:: unix_time_as_millis ( ) ;
287287 peer_store. remove_disconnected_peer ( & addr) ;
288- assert ! ( peer_store. fetch_addrs_to_feeler( 1 ) . is_empty( ) ) ;
288+ assert ! ( peer_store. fetch_addrs_to_feeler( 1 , |_| true ) . is_empty( ) ) ;
289289}
290290
291291#[ test]
@@ -581,10 +581,10 @@ fn test_addr_unique() {
581581 . unwrap ( ) ;
582582 peer_store. add_addr ( addr_1, Flags :: COMPATIBILITY ) . unwrap ( ) ;
583583 assert_eq ! ( peer_store. addr_manager( ) . addrs_iter( ) . count( ) , 2 ) ;
584- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 2 ) ;
584+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 2 ) ;
585585
586586 peer_store. add_addr ( addr, Flags :: COMPATIBILITY ) . unwrap ( ) ;
587- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 2 ) ;
587+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 2 ) ;
588588
589589 assert_eq ! ( peer_store. addr_manager( ) . addrs_iter( ) . count( ) , 2 ) ;
590590}
@@ -597,8 +597,8 @@ fn test_only_tcp_store() {
597597 peer_store
598598 . add_addr ( addr. clone ( ) , Flags :: COMPATIBILITY )
599599 . unwrap ( ) ;
600- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 1 ) ;
601- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 1 ) [ 0 ] . addr, {
600+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 1 ) ;
601+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 1 , |_| true ) [ 0 ] . addr, {
602602 addr. pop( ) ;
603603 addr
604604 } ) ;
@@ -618,6 +618,6 @@ fn test_support_dns_store() {
618618 peer_store
619619 . add_addr ( addr. clone ( ) , Flags :: COMPATIBILITY )
620620 . unwrap ( ) ;
621- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 ) . len( ) , 1 ) ;
622- assert_eq ! ( peer_store. fetch_addrs_to_feeler( 1 ) [ 0 ] . addr, addr) ;
621+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 2 , |_| true ) . len( ) , 1 ) ;
622+ assert_eq ! ( peer_store. fetch_addrs_to_feeler( 1 , |_| true ) [ 0 ] . addr, addr) ;
623623}
0 commit comments