fn send_capacity() {
        let mut buf = [0; 65535];

        let mut config = Config::new(crate::PROTOCOL_VERSION).unwrap();
        config
            .load_cert_chain_from_pem_file("examples/cert.crt")
            .unwrap();
        config
            .load_priv_key_from_pem_file("examples/cert.key")
            .unwrap();
        config
            .set_application_protos(b"\x06proto1\x06proto2")
            .unwrap();
        config.set_initial_max_data(100000);
        config.set_initial_max_stream_data_bidi_local(10000);
        config.set_initial_max_stream_data_bidi_remote(10000);
        config.set_initial_max_streams_bidi(10);
        config.verify_peer(false);

        let mut pipe = testing::Pipe::with_config(&mut config).unwrap();
        assert_eq!(pipe.handshake(), Ok(()));

        assert_eq!(pipe.client.stream_send(0, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));

        assert_eq!(pipe.client.stream_send(4, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));

        assert_eq!(pipe.client.stream_send(8, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));

        assert_eq!(pipe.client.stream_send(12, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));

        let mut r = pipe.server.readable().collect::<Vec<u64>>();
        assert_eq!(r.len(), 4);

        r.sort();

        assert_eq!(r, [0, 4, 8, 12]);

        assert_eq!(pipe.server.stream_recv(0, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(4, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(8, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(12, &mut buf), Ok((6, true)));

        assert_eq!(pipe.server.tx_cap, 12000);

        assert_eq!(pipe.server.stream_send(0, &buf[..5000], false), Ok(5000));
        assert_eq!(pipe.server.stream_send(4, &buf[..5000], false), Ok(5000));
        assert_eq!(pipe.server.stream_send(8, &buf[..5000], false), Ok(2000));

        // No more connection send capacity.
        assert_eq!(pipe.server.stream_send(12, &buf[..5000], false), Ok(0));
        assert_eq!(pipe.server.tx_cap, 0);

        assert_eq!(pipe.advance(), Ok(()));
    }
/// Tests that connection-level send capacity decreases as more stream data
/// is buffered.
Tests that connection-level send capacity decreases as more stream data
is buffered.
Tests that connection - level send capacity decreases as more stream data is buffered .
fn send_capacity() {
        let mut buf = [0; 65535];
        let mut config = Config::new(crate::PROTOCOL_VERSION).unwrap();
        config
            .load_cert_chain_from_pem_file("examples/cert.crt")
            .unwrap();
        config
            .load_priv_key_from_pem_file("examples/cert.key")
            .unwrap();
        config
            .set_application_protos(b"\x06proto1\x06proto2")
            .unwrap();
        config.set_initial_max_data(100000);
        config.set_initial_max_stream_data_bidi_local(10000);
        config.set_initial_max_stream_data_bidi_remote(10000);
        config.set_initial_max_streams_bidi(10);
        config.verify_peer(false);
        let mut pipe = testing::Pipe::with_config(&mut config).unwrap();
        assert_eq!(pipe.handshake(), Ok(()));
        assert_eq!(pipe.client.stream_send(0, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));
        assert_eq!(pipe.client.stream_send(4, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));
        assert_eq!(pipe.client.stream_send(8, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));
        assert_eq!(pipe.client.stream_send(12, b"hello!", true), Ok(6));
        assert_eq!(pipe.advance(), Ok(()));
        let mut r = pipe.server.readable().collect::<Vec<u64>>();
        assert_eq!(r.len(), 4);
        r.sort();
        assert_eq!(r, [0, 4, 8, 12]);
        assert_eq!(pipe.server.stream_recv(0, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(4, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(8, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.stream_recv(12, &mut buf), Ok((6, true)));
        assert_eq!(pipe.server.tx_cap, 12000);
        assert_eq!(pipe.server.stream_send(0, &buf[..5000], false), Ok(5000));
        assert_eq!(pipe.server.stream_send(4, &buf[..5000], false), Ok(5000));
        assert_eq!(pipe.server.stream_send(8, &buf[..5000], false), Ok(2000));
        // No more connection send capacity.
        assert_eq!(pipe.server.stream_send(12, &buf[..5000], false), Ok(0));
        assert_eq!(pipe.server.tx_cap, 0);
        assert_eq!(pipe.advance(), Ok(()));
    }
fn send_capacity ( ) { let mut buf = [ 0 ; 65535 ] ; let mut config = Config :: new ( crate :: PROTOCOL_VERSION ) . unwrap ( ) ; config . load_cert_chain_from_pem_file ( " " ) . unwrap ( ) ; config . load_priv_key_from_pem_file ( " " ) . unwrap ( ) ; config . set_application_protos ( b" \x06 \x06 " ) . unwrap ( ) ; config . set_initial_max_data ( 100000 ) ; config . set_initial_max_stream_data_bidi_local ( 10000 ) ; config . set_initial_max_stream_data_bidi_remote ( 10000 ) ; config . set_initial_max_streams_bidi ( 10 ) ; config . verify_peer ( false ) ; let mut pipe = testing :: Pipe :: with_config ( & mut config ) . unwrap ( ) ; assert_eq ! ( pipe handshake ( ) Ok ( ( ) ) ) ; assert_eq ! ( pipe client stream_send ( 0 b" " true ) Ok ( 6 ) ) ; assert_eq ! ( pipe advance ( ) Ok ( ( ) ) ) ; assert_eq ! ( pipe client stream_send ( 4 b" " true ) Ok ( 6 ) ) ; assert_eq ! ( pipe advance ( ) Ok ( ( ) ) ) ; assert_eq ! ( pipe client stream_send ( 8 b" " true ) Ok ( 6 ) ) ; assert_eq ! ( pipe advance ( ) Ok ( ( ) ) ) ; assert_eq ! ( pipe client stream_send ( 12 b" " true ) Ok ( 6 ) ) ; assert_eq ! ( pipe advance ( ) Ok ( ( ) ) ) ; let mut r = pipe . server . readable ( ) . collect :: < Vec < u64 > > ( ) ; assert_eq ! ( r len ( ) 4 ) ; r . sort ( ) ; assert_eq ! ( r [ 0 4 8 12 ] ) ; assert_eq ! ( pipe server stream_recv ( 0 mut buf ) Ok ( ( 6 true ) ) ) ; assert_eq ! ( pipe server stream_recv ( 4 mut buf ) Ok ( ( 6 true ) ) ) ; assert_eq ! ( pipe server stream_recv ( 8 mut buf ) Ok ( ( 6 true ) ) ) ; assert_eq ! ( pipe server stream_recv ( 12 mut buf ) Ok ( ( 6 true ) ) ) ; assert_eq ! ( pipe server tx_cap 12000 ) ; assert_eq ! ( pipe server stream_send ( 0 buf [ 5000 ] false ) Ok ( 5000 ) ) ; assert_eq ! ( pipe server stream_send ( 4 buf [ 5000 ] false ) Ok ( 5000 ) ) ; assert_eq ! ( pipe server stream_send ( 8 buf [ 5000 ] false ) Ok ( 2000 ) ) ; // No more connection send capacity. assert_eq ! ( pipe server stream_send ( 12 buf [ 5000 ] false ) Ok ( 0 ) ) ; assert_eq ! ( pipe server tx_cap 0 ) ; assert_eq ! ( pipe advance ( ) Ok ( ( ) ) ) ; }
Tests that connection-level send capacity decreases as more stream data
is buffered.
Tests that connection - level send capacity decreases as more stream data is buffered .