pub fn modify_encoded_stream_helper<F: FnOnce(StreamSlice) -> Stream>(
    state_manager: StateManagerImpl,
    slice: CertifiedStreamSlice,
    f: F,
) -> (StateManagerImpl, CertifiedStreamSlice) {
    let (_subnet, decoded_slice) =
        stream_encoding::decode_stream_slice(&slice.payload[..]).unwrap();

    let modified_stream = f(decoded_slice);

    let (_height, mut state) = state_manager.take_tip();

    let mut streams = state.take_streams();
    streams.clear();
    streams.insert(subnet_test_id(42), modified_stream);
    state.put_streams(streams);

    state_manager.commit_and_certify(state, Height::new(2), CertificationScope::Metadata);

    certify_height(&state_manager, Height::new(2));

    let new_slice = state_manager
        .encode_certified_stream_slice(subnet_test_id(42), None, None, None, None)
        .expect("failed to encode certified stream");

    (
        state_manager,
        CertifiedStreamSlice {
            payload: new_slice.payload,
            merkle_proof: slice.merkle_proof,
            certification: slice.certification,
        },
    )
}
/// Fixture for modifying the payload of a `CertifiedStreamSlice.
///
/// Decodes the given `slice` and applies `f` to the decoded slice to obtain a
/// new stream. The obtained stream is then committed, certified, and encoded
/// into a `CertifiedStreamSlice` using `state_manager`. The function returns
/// the `state_manager` with the new state committed and a
/// `CertifiedStreamSlice` having `payload` set to the newly encoded payload,
/// while retaining the remaining fields from `slice`.
///
///
/// # Panics
/// Whenever encoding and/or decoding would under normal circumstances return an
/// error.
Fixture for modifying the payload of a `CertifiedStreamSlice.
Decodes the given `slice` and applies `f` to the decoded slice to obtain a
new stream. The obtained stream is then committed, certified, and encoded
into a `CertifiedStreamSlice` using `state_manager`.
Fixture for modifying the payload of a ` CertifiedStreamSlice . Decodes the given ` slice ` and applies ` f ` to the decoded slice to obtain a new stream . The obtained stream is then committed certified and encoded into a ` CertifiedStreamSlice ` using ` state_manager ` .
pub fn modify_encoded_stream_helper<F: FnOnce(StreamSlice) -> Stream>(
    state_manager: StateManagerImpl,
    slice: CertifiedStreamSlice,
    f: F,
) -> (StateManagerImpl, CertifiedStreamSlice) {
    let (_subnet, decoded_slice) =
        stream_encoding::decode_stream_slice(&slice.payload[..]).unwrap();
    let modified_stream = f(decoded_slice);
    let (_height, mut state) = state_manager.take_tip();
    let mut streams = state.take_streams();
    streams.clear();
    streams.insert(subnet_test_id(42), modified_stream);
    state.put_streams(streams);
    state_manager.commit_and_certify(state, Height::new(2), CertificationScope::Metadata);
    certify_height(&state_manager, Height::new(2));
    let new_slice = state_manager
        .encode_certified_stream_slice(subnet_test_id(42), None, None, None, None)
        .expect("failed to encode certified stream");
    (
        state_manager,
        CertifiedStreamSlice {
            payload: new_slice.payload,
            merkle_proof: slice.merkle_proof,
            certification: slice.certification,
        },
    )
}
pub fn modify_encoded_stream_helper < F : FnOnce ( StreamSlice ) -> Stream > ( state_manager : StateManagerImpl , slice : CertifiedStreamSlice , f : F , ) -> ( StateManagerImpl , CertifiedStreamSlice ) { let ( _subnet , decoded_slice ) = stream_encoding :: decode_stream_slice ( & slice . payload [ .. ] ) . unwrap ( ) ; let modified_stream = f ( decoded_slice ) ; let ( _height , mut state ) = state_manager . take_tip ( ) ; let mut streams = state . take_streams ( ) ; streams . clear ( ) ; streams . insert ( subnet_test_id ( 42 ) , modified_stream ) ; state . put_streams ( streams ) ; state_manager . commit_and_certify ( state , Height :: new ( 2 ) , CertificationScope :: Metadata ) ; certify_height ( & state_manager , Height :: new ( 2 ) ) ; let new_slice = state_manager . encode_certified_stream_slice ( subnet_test_id ( 42 ) , None , None , None , None ) . expect ( " " ) ; ( state_manager , CertifiedStreamSlice { payload : new_slice . payload , merkle_proof : slice . merkle_proof , certification : slice . certification , } , ) }
Fixture for modifying the payload of a `CertifiedStreamSlice.
Fixture for modifying the payload of a ` CertifiedStreamSlice .
state_manager
StateManagerImpl
slice
CertifiedStreamSlice
f
F
state_manager
StateManagerImpl
slice
CertifiedStreamSlice
f
F
panics
Whenever encoding and/or decoding would under normal circumstances return an
error.
Whenever encoding and / or decoding would under normal circumstances return an error .