@@ -2577,15 +2577,6 @@ mod tests {
2577
2577
( join_handle, reader, writer, rx, cancel_token)
2578
2578
}
2579
2579
2580
- async fn send_frame < W > ( writer : W , bytes : bytes:: Bytes ) -> W
2581
- where
2582
- W : AsyncWrite + Unpin ,
2583
- {
2584
- let mut fw = FrameWrite :: new ( writer, bytes) ;
2585
- fw. send ( ) . await . unwrap ( ) ;
2586
- fw. complete ( )
2587
- }
2588
-
2589
2580
async fn write_stream < M , W > (
2590
2581
mut writer : W ,
2591
2582
session_id : u64 ,
@@ -2866,7 +2857,9 @@ mod tests {
2866
2857
. await ;
2867
2858
2868
2859
for i in 0u64 ..5u64 {
2869
- writer = send_frame ( writer, serialize_ack ( i) ) . await ;
2860
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( i) )
2861
+ . await
2862
+ . unwrap ( ) ;
2870
2863
}
2871
2864
// Wait for the acks to be processed by NetTx.
2872
2865
RealClock . sleep ( Duration :: from_secs ( 3 ) ) . await ;
@@ -2927,7 +2920,9 @@ mod tests {
2927
2920
// In the last iteration, ack part of the messages. This should
2928
2921
// prune them from future resent.
2929
2922
if i == n - 1 {
2930
- writer = send_frame ( writer, serialize_ack ( 1 ) ) . await ;
2923
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 1 ) )
2924
+ . await
2925
+ . unwrap ( ) ;
2931
2926
// Wait for the acks to be processed by NetTx.
2932
2927
RealClock . sleep ( Duration :: from_secs ( 3 ) ) . await ;
2933
2928
}
@@ -2983,9 +2978,15 @@ mod tests {
2983
2978
if i == n - 1 {
2984
2979
// Intentionally ack 1 again to verify it is okay to ack
2985
2980
// messages that was already acked.
2986
- writer = send_frame ( writer, serialize_ack ( 1 ) ) . await ;
2987
- writer = send_frame ( writer, serialize_ack ( 2 ) ) . await ;
2988
- writer = send_frame ( writer, serialize_ack ( 3 ) ) . await ;
2981
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 1 ) )
2982
+ . await
2983
+ . unwrap ( ) ;
2984
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 2 ) )
2985
+ . await
2986
+ . unwrap ( ) ;
2987
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 3 ) )
2988
+ . await
2989
+ . unwrap ( ) ;
2989
2990
// Wait for the acks to be processed by NetTx.
2990
2991
RealClock . sleep ( Duration :: from_secs ( 3 ) ) . await ;
2991
2992
}
@@ -3017,7 +3018,9 @@ mod tests {
3017
3018
3018
3019
// In the last iteration, ack part of the messages from the 2nd send.
3019
3020
if i == n - 1 {
3020
- writer = send_frame ( writer, serialize_ack ( 7 ) ) . await ;
3021
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 7 ) )
3022
+ . await
3023
+ . unwrap ( ) ;
3021
3024
// Wait for the acks to be processed by NetTx.
3022
3025
RealClock . sleep ( Duration :: from_secs ( 3 ) ) . await ;
3023
3026
}
@@ -3061,7 +3064,9 @@ mod tests {
3061
3064
let ( mut reader, mut writer) = take_receiver ( & receiver_storage) . await ;
3062
3065
verify_stream ( & mut reader, & [ ( 0u64 , 100u64 ) ] , None , line ! ( ) ) . await ;
3063
3066
// ack it
3064
- writer = send_frame ( writer, serialize_ack ( 0 ) ) . await ;
3067
+ writer = FrameWrite :: write_frame ( writer, serialize_ack ( 0 ) )
3068
+ . await
3069
+ . unwrap ( ) ;
3065
3070
// confirm Tx received ack
3066
3071
//
3067
3072
// Using `is_err` to confirm the message is delivered/acked is confusing,
@@ -3072,7 +3077,9 @@ mod tests {
3072
3077
// Although Tx did not actually send seq=1, we still ack it from Rx to
3073
3078
// pretend Tx already sent it, just it did not know it was sent
3074
3079
// successfully.
3075
- let _ = send_frame ( writer, serialize_ack ( 1 ) ) . await ;
3080
+ let _ = FrameWrite :: write_frame ( writer, serialize_ack ( 1 ) )
3081
+ . await
3082
+ . unwrap ( ) ;
3076
3083
3077
3084
let ( return_channel_tx, return_channel_rx) = oneshot:: channel ( ) ;
3078
3085
net_tx. try_post ( 101 , return_channel_tx) . unwrap ( ) ;
@@ -3104,7 +3111,9 @@ mod tests {
3104
3111
// Confirm message is sent to rx.
3105
3112
verify_stream ( & mut reader, & [ ( 0u64 , 100u64 ) ] , None , line ! ( ) ) . await ;
3106
3113
// ack it
3107
- let _ = send_frame ( writer, serialize_ack ( 0 ) ) . await ;
3114
+ let _ = FrameWrite :: write_frame ( writer, serialize_ack ( 0 ) )
3115
+ . await
3116
+ . unwrap ( ) ;
3108
3117
RealClock . sleep ( Duration :: from_secs ( 3 ) ) . await ;
3109
3118
// Channel should be still alive because ack was sent.
3110
3119
assert ! ( !tx_status. has_changed( ) . unwrap( ) ) ;
0 commit comments