Skip to content

Commit afc0f0b

Browse files
committed
tests: Ensure empty with nonempty frames can interleave
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
1 parent ec76929 commit afc0f0b

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

tests/protocol/notification.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ async fn zero_byte_handshake(transport1: Transport, transport2: Transport, hands
22232223
);
22242224

22252225
// This step ensures we have not messed with the notification frames.
2226-
tracing::info!("Send async notification...");
2226+
tracing::info!("Send sync notification...");
22272227
handle1.send_sync_notification(peer2, vec![1, 3, 3, 7]).unwrap();
22282228
handle2.send_sync_notification(peer1, vec![1, 3, 3, 8]).unwrap();
22292229

@@ -2241,6 +2241,46 @@ async fn zero_byte_handshake(transport1: Transport, transport2: Transport, hands
22412241
notification: BytesMut::from(&[1, 3, 3, 8][..]),
22422242
}
22432243
);
2244+
2245+
// Ensure the handle can send empty notifications.
2246+
tracing::info!("Send empty sync notification...");
2247+
handle1.send_sync_notification(peer2, vec![]).unwrap();
2248+
handle2.send_sync_notification(peer1, vec![]).unwrap();
2249+
2250+
assert_eq!(
2251+
handle2.next().await.unwrap(),
2252+
NotificationEvent::NotificationReceived {
2253+
peer: peer1,
2254+
notification: BytesMut::from(&[][..]),
2255+
}
2256+
);
2257+
assert_eq!(
2258+
handle1.next().await.unwrap(),
2259+
NotificationEvent::NotificationReceived {
2260+
peer: peer2,
2261+
notification: BytesMut::from(&[][..]),
2262+
}
2263+
);
2264+
2265+
// Double check non-empty notifications.
2266+
tracing::info!("Send sync notification...");
2267+
handle1.send_sync_notification(peer2, vec![1, 3, 3, 9]).unwrap();
2268+
handle2.send_sync_notification(peer1, vec![1, 3, 3, 4]).unwrap();
2269+
2270+
assert_eq!(
2271+
handle2.next().await.unwrap(),
2272+
NotificationEvent::NotificationReceived {
2273+
peer: peer1,
2274+
notification: BytesMut::from(&[1, 3, 3, 9][..]),
2275+
}
2276+
);
2277+
assert_eq!(
2278+
handle1.next().await.unwrap(),
2279+
NotificationEvent::NotificationReceived {
2280+
peer: peer2,
2281+
notification: BytesMut::from(&[1, 3, 3, 4][..]),
2282+
}
2283+
);
22442284
}
22452285

22462286
#[tokio::test]

0 commit comments

Comments
 (0)