Skip to content

Commit 65657a6

Browse files
committed
Other discussion: nodejs/node#30030
Signed-off-by: Kevin Leimkuhler <[email protected]>
1 parent 6cecb70 commit 65657a6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/udp_socket.rs

+32
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@ const ID1: Token = Token(2);
2828
const ID2: Token = Token(3);
2929
const ID3: Token = Token(4);
3030

31+
#[test]
32+
fn empty_datagram() {
33+
const EMPTY: &[u8] = b"";
34+
35+
let (mut poll, mut events) = init_with_poll();
36+
let mut s1 = UdpSocket::bind(any_local_address()).unwrap();
37+
let mut s2 = UdpSocket::bind(any_local_address()).unwrap();
38+
39+
poll.registry()
40+
.register(&mut s1, ID1, Interest::WRITABLE)
41+
.unwrap();
42+
poll.registry()
43+
.register(&mut s2, ID2, Interest::READABLE)
44+
.unwrap();
45+
46+
expect_events(
47+
&mut poll,
48+
&mut events,
49+
vec![ExpectEvent::new(ID1, Interest::WRITABLE)],
50+
);
51+
52+
checked_write!(s1.send_to(EMPTY, s2.local_addr().unwrap()));
53+
54+
let mut buf = [0; 10];
55+
expect_events(
56+
&mut poll,
57+
&mut events,
58+
vec![ExpectEvent::new(ID2, Interest::READABLE)],
59+
);
60+
expect_read!(s2.recv_from(&mut buf), EMPTY, s1.local_addr().unwrap());
61+
}
62+
3163
#[test]
3264
fn is_send_and_sync() {
3365
assert_send::<UdpSocket>();

0 commit comments

Comments
 (0)