@@ -19,6 +19,9 @@ use parking_lot::RwLock;
19
19
use std:: { collections:: HashMap , sync:: Arc , time:: Duration } ;
20
20
use tokio:: sync:: { mpsc, oneshot} ;
21
21
22
+ /// Default UDP port number to use for tests requiring UDP exposure
23
+ pub const DEFAULT_UDP_PORT : u16 = 0 ;
24
+
22
25
fn _connected_state ( ) -> NodeStatus {
23
26
NodeStatus {
24
27
state : ConnectionState :: Connected ,
@@ -105,14 +108,14 @@ async fn test_updating_connection_on_ping() {
105
108
let ip = "127.0.0.1" . parse ( ) . unwrap ( ) ;
106
109
let enr = EnrBuilder :: new ( "v4" )
107
110
. ip4 ( ip)
108
- . udp4 ( 10001 )
111
+ . udp4 ( DEFAULT_UDP_PORT )
109
112
. build ( & enr_key1)
110
113
. unwrap ( ) ;
111
114
let ip2 = "127.0.0.1" . parse ( ) . unwrap ( ) ;
112
115
let enr_key2 = CombinedKey :: generate_secp256k1 ( ) ;
113
116
let enr2 = EnrBuilder :: new ( "v4" )
114
117
. ip4 ( ip2)
115
- . udp4 ( 10002 )
118
+ . udp4 ( DEFAULT_UDP_PORT )
116
119
. build ( & enr_key2)
117
120
. unwrap ( ) ;
118
121
@@ -141,7 +144,7 @@ async fn test_updating_connection_on_ping() {
141
144
body : ResponseBody :: Pong {
142
145
enr_seq : 2 ,
143
146
ip : ip2. into ( ) ,
144
- port : 10002 ,
147
+ port : DEFAULT_UDP_PORT ,
145
148
} ,
146
149
} ;
147
150
@@ -173,15 +176,15 @@ async fn test_connection_direction_on_inject_session_established() {
173
176
let ip = std:: net:: Ipv4Addr :: LOCALHOST ;
174
177
let enr = EnrBuilder :: new ( "v4" )
175
178
. ip4 ( ip)
176
- . udp4 ( 10001 )
179
+ . udp4 ( DEFAULT_UDP_PORT )
177
180
. build ( & enr_key1)
178
181
. unwrap ( ) ;
179
182
180
183
let enr_key2 = CombinedKey :: generate_secp256k1 ( ) ;
181
184
let ip2 = std:: net:: Ipv4Addr :: LOCALHOST ;
182
185
let enr2 = EnrBuilder :: new ( "v4" )
183
186
. ip4 ( ip2)
184
- . udp4 ( 10002 )
187
+ . udp4 ( DEFAULT_UDP_PORT )
185
188
. build ( & enr_key2)
186
189
. unwrap ( ) ;
187
190
0 commit comments