fn finish_retransmit() {
    let _guard = subscribe();
    let mut pair = Pair::default();
    let (client_ch, server_ch) = pair.connect();

    let s = pair.client_conn_mut(client_ch).open(Dir::Uni).unwrap();

    const MSG: &[u8] = b"hello";
    pair.client_conn_mut(client_ch).write(s, MSG).unwrap();
    pair.drive_client(); // send data to server
    pair.server.inbound.clear(); // Lose it

    // Send FIN
    pair.client_conn_mut(client_ch).finish(s).unwrap();
    pair.drive_client();
    // Process FIN
    pair.drive_server();
    // Receive FIN ack, but no data ack
    pair.drive_client();
    // Check for premature finish from FIN ack
    assert_matches!(pair.client_conn_mut(client_ch).poll(), None);
    // Recover
    pair.drive();
    assert_matches!(
        pair.client_conn_mut(client_ch).poll(),
        Some(Event::Stream(StreamEvent::Finished { id })) if id == s
    );

    assert_matches!(
        pair.server_conn_mut(server_ch).poll(),
        Some(Event::Stream(StreamEvent::Opened { dir: Dir::Uni }))
    );

    assert_matches!(pair.server_conn_mut(server_ch).accept(Dir::Uni), Some(stream) if stream == s);
    assert_matches!(
        pair.server_conn_mut(server_ch).read_unordered(s),
        Ok(Some((ref data, 0))) if data == MSG
    );
    assert_matches!(pair.server_conn_mut(server_ch).read_unordered(s), Ok(None));
}
/// Ensure that we don't yield a finish event while there's still unacknowledged data
Ensure that we don't yield a finish event while there's still unacknowledged data
Ensure that we don ' t yield a finish event while there ' s still unacknowledged data
fn finish_retransmit() {
    let _guard = subscribe();
    let mut pair = Pair::default();
    let (client_ch, server_ch) = pair.connect();
    let s = pair.client_conn_mut(client_ch).open(Dir::Uni).unwrap();
    const MSG: &[u8] = b"hello";
    pair.client_conn_mut(client_ch).write(s, MSG).unwrap();
    pair.drive_client(); // send data to server
    pair.server.inbound.clear(); // Lose it
    // Send FIN
    pair.client_conn_mut(client_ch).finish(s).unwrap();
    pair.drive_client();
    // Process FIN
    pair.drive_server();
    // Receive FIN ack, but no data ack
    pair.drive_client();
    // Check for premature finish from FIN ack
    assert_matches!(pair.client_conn_mut(client_ch).poll(), None);
    // Recover
    pair.drive();
    assert_matches!(
        pair.client_conn_mut(client_ch).poll(),
        Some(Event::Stream(StreamEvent::Finished { id })) if id == s
    );
    assert_matches!(
        pair.server_conn_mut(server_ch).poll(),
        Some(Event::Stream(StreamEvent::Opened { dir: Dir::Uni }))
    );
    assert_matches!(pair.server_conn_mut(server_ch).accept(Dir::Uni), Some(stream) if stream == s);
    assert_matches!(
        pair.server_conn_mut(server_ch).read_unordered(s),
        Ok(Some((ref data, 0))) if data == MSG
    );
    assert_matches!(pair.server_conn_mut(server_ch).read_unordered(s), Ok(None));
}
fn finish_retransmit ( ) { let _guard = subscribe ( ) ; let mut pair = Pair :: default ( ) ; let ( client_ch , server_ch ) = pair . connect ( ) ; let s = pair . client_conn_mut ( client_ch ) . open ( Dir :: Uni ) . unwrap ( ) ; const MSG : & [ u8 ] = b" " ; pair . client_conn_mut ( client_ch ) . write ( s , MSG ) . unwrap ( ) ; pair . drive_client ( ) ; // send data to server pair . server . inbound . clear ( ) ; // Lose it // Send FIN pair . client_conn_mut ( client_ch ) . finish ( s ) . unwrap ( ) ; pair . drive_client ( ) ; // Process FIN pair . drive_server ( ) ; // Receive FIN ack, but no data ack pair . drive_client ( ) ; // Check for premature finish from FIN ack assert_matches ! ( pair client_conn_mut ( client_ch ) poll ( ) None ) ; // Recover pair . drive ( ) ; assert_matches ! ( pair client_conn_mut ( client_ch ) poll ( ) Some ( Event Stream ( StreamEvent Finished { id } ) ) if id s ) ; assert_matches ! ( pair server_conn_mut ( server_ch ) poll ( ) Some ( Event Stream ( StreamEvent Opened { dir Dir Uni } ) ) ) ; assert_matches ! ( pair server_conn_mut ( server_ch ) accept ( Dir Uni ) Some ( stream ) if stream s ) ; assert_matches ! ( pair server_conn_mut ( server_ch ) read_unordered ( s ) Ok ( Some ( ( ref data 0 ) ) ) if data MSG ) ; assert_matches ! ( pair server_conn_mut ( server_ch ) read_unordered ( s ) Ok ( None ) ) ; }
Ensure that we don't yield a finish event while there's still unacknowledged data
Ensure that we don ' t yield a finish event while there ' s still unacknowledged data