@@ -22,7 +22,7 @@ use p2p::{
22
22
config:: { BanDuration , BanThreshold } ,
23
23
types:: socket_address:: SocketAddress ,
24
24
} ;
25
- use p2p_test_utils:: { assert_no_value_in_channel , get_value_from_channel } ;
25
+ use p2p_test_utils:: { expect_no_recv , expect_recv } ;
26
26
27
27
use crate :: {
28
28
crawler_p2p:: crawler_manager:: tests:: mock_manager:: {
@@ -41,15 +41,15 @@ async fn basic() {
41
41
state. node_online ( node1) ;
42
42
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
43
43
assert_eq ! (
44
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
44
+ expect_recv! ( command_rx) ,
45
45
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
46
46
) ;
47
47
48
48
// Node goes offline, DNS record removed
49
49
state. node_offline ( node1) ;
50
50
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
51
51
assert_eq ! (
52
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
52
+ expect_recv! ( command_rx) ,
53
53
DnsServerCommand :: DelAddress ( node1. socket_addr( ) . ip( ) )
54
54
) ;
55
55
}
@@ -72,7 +72,7 @@ async fn long_offline() {
72
72
state. node_online ( node1) ;
73
73
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 24 * 60 ) . await ;
74
74
assert_eq ! (
75
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
75
+ expect_recv! ( command_rx) ,
76
76
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
77
77
) ;
78
78
}
@@ -90,21 +90,21 @@ async fn announced_online() {
90
90
91
91
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
92
92
assert_eq ! (
93
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
93
+ expect_recv! ( command_rx) ,
94
94
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
95
95
) ;
96
96
97
97
state. announce_address ( node1, node2) ;
98
98
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
99
99
assert_eq ! (
100
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
100
+ expect_recv! ( command_rx) ,
101
101
DnsServerCommand :: AddAddress ( node2. socket_addr( ) . ip( ) )
102
102
) ;
103
103
104
104
state. announce_address ( node2, node3) ;
105
105
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
106
106
assert_eq ! (
107
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
107
+ expect_recv! ( command_rx) ,
108
108
DnsServerCommand :: AddAddress ( node3. socket_addr( ) . ip( ) )
109
109
) ;
110
110
@@ -121,7 +121,7 @@ async fn announced_offline() {
121
121
122
122
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 60 ) . await ;
123
123
assert_eq ! (
124
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
124
+ expect_recv! ( command_rx) ,
125
125
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
126
126
) ;
127
127
assert_eq ! ( state. connection_attempts. lock( ) . unwrap( ) . len( ) , 1 ) ;
@@ -136,7 +136,7 @@ async fn announced_offline() {
136
136
state. announce_address ( node1, node2) ;
137
137
advance_time ( & mut crawler, & time_getter, Duration :: from_secs ( 60 ) , 24 * 60 ) . await ;
138
138
assert_eq ! (
139
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
139
+ expect_recv! ( command_rx) ,
140
140
DnsServerCommand :: AddAddress ( node2. socket_addr( ) . ip( ) )
141
141
) ;
142
142
assert_eq ! ( state. connection_attempts. lock( ) . unwrap( ) . len( ) , 3 ) ;
@@ -164,14 +164,14 @@ async fn private_ip() {
164
164
165
165
// Check that only nodes with public addresses and on the default port are added to DNS
166
166
assert_eq ! (
167
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
167
+ expect_recv! ( command_rx) ,
168
168
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
169
169
) ;
170
170
assert_eq ! (
171
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
171
+ expect_recv! ( command_rx) ,
172
172
DnsServerCommand :: AddAddress ( node2. socket_addr( ) . ip( ) )
173
173
) ;
174
- assert_no_value_in_channel ( & mut command_rx) . await ;
174
+ expect_no_recv ! ( command_rx) ;
175
175
176
176
// Check that all reachable nodes are stored in the DB
177
177
assert_known_addresses ( & crawler, & [ node1, node2, node3, node4, node5, node6] ) ;
@@ -202,14 +202,14 @@ async fn ban_unban() {
202
202
203
203
// Only normal nodes are added to DNS
204
204
assert_eq ! (
205
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
205
+ expect_recv! ( command_rx) ,
206
206
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
207
207
) ;
208
208
assert_eq ! (
209
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
209
+ expect_recv! ( command_rx) ,
210
210
DnsServerCommand :: AddAddress ( node3. socket_addr( ) . ip( ) )
211
211
) ;
212
- assert_no_value_in_channel ( & mut command_rx) . await ;
212
+ expect_no_recv ! ( command_rx) ;
213
213
214
214
// node2 is banned
215
215
assert_banned_addresses ( & crawler, & [ ( node2. as_bannable ( ) , node2_ban_end_time) ] ) ;
@@ -226,7 +226,7 @@ async fn ban_unban() {
226
226
227
227
// Check that it's been removed from DNS.
228
228
assert_eq ! (
229
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
229
+ expect_recv! ( command_rx) ,
230
230
DnsServerCommand :: DelAddress ( node1. socket_addr( ) . ip( ) )
231
231
) ;
232
232
@@ -252,7 +252,7 @@ async fn ban_unban() {
252
252
( node2. as_bannable ( ) , node2_ban_end_time) ,
253
253
] ,
254
254
) ;
255
- assert_no_value_in_channel ( & mut command_rx) . await ;
255
+ expect_no_recv ! ( command_rx) ;
256
256
257
257
// Wait enough time for node2 to be unbanned.
258
258
let time_until_node2_unban =
@@ -262,7 +262,7 @@ async fn ban_unban() {
262
262
// node2 is no longer banned; its address has been added to DNS.
263
263
assert_banned_addresses ( & crawler, & [ ( node1. as_bannable ( ) , node1_ban_end_time) ] ) ;
264
264
assert_eq ! (
265
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
265
+ expect_recv! ( command_rx) ,
266
266
DnsServerCommand :: AddAddress ( node2. socket_addr( ) . ip( ) )
267
267
) ;
268
268
@@ -274,7 +274,7 @@ async fn ban_unban() {
274
274
// node1 is no longer banned; its address has been added to DNS.
275
275
assert_banned_addresses ( & crawler, & [ ] ) ;
276
276
assert_eq ! (
277
- get_value_from_channel ( & mut command_rx) . await . unwrap ( ) ,
277
+ expect_recv! ( command_rx) ,
278
278
DnsServerCommand :: AddAddress ( node1. socket_addr( ) . ip( ) )
279
279
) ;
280
280
}
0 commit comments