fn prepare(
    time_source: &dyn TimeSource,
    pool: &mut IngressPoolImpl,
    now: Time,
    num: usize,
) -> Time {
    let mut changeset = ChangeSet::new();
    let ingress_size = 1024;
    let mut rng = rand::thread_rng();
    for i in 0..num {
        // Only 10% of them will be considered valid
        let expiry = std::time::Duration::from_millis(
            rng.gen::<u64>() % (10 * (MAX_INGRESS_TTL.as_millis() as u64)),
        );
        let ingress = SignedIngressBuilder::new()
            .method_name("provisional_create_canister_with_cycles")
            .method_payload(vec![0; ingress_size])
            .nonce(i as u64)
            .expiry_time(now + expiry)
            .canister_id(IC_00)
            .build();
        let message_id = IngressMessageId::from(&ingress);
        let attribute = IngressMessageAttribute::new(&ingress);
        let peer_id = (i % 10) as u64;
        let integrity_hash = ic_crypto::crypto_hash(ingress.binary()).get();
        pool.insert(UnvalidatedArtifact {
            message: ingress,
            peer_id: node_test_id(peer_id),
            timestamp: time_source.get_relative_time(),
        });
        changeset.push(ChangeAction::MoveToValidated((
            message_id,
            node_test_id(peer_id),
            0,
            attribute,
            integrity_hash,
        )));
    }
    pool.apply_changeset(changeset);
    assert_eq!(pool.unvalidated().size(), 0);
    assert_eq!(pool.validated().size(), num);
    now + 5 * MAX_INGRESS_TTL
}
/// Prepare pool with a set of ingress messages, only about 10% of them will
/// be considered as valid according to expiry restrictions (not expired & not
/// too far in the future).
///
/// Return the mean of all expiry time.
Prepare pool with a set of ingress messages, only about 10% of them will
be considered as valid according to expiry restrictions (not expired & not
too far in the future).

Return the mean of all expiry time.
Prepare pool with a set of ingress messages only about 10% of them will be considered as valid according to expiry restrictions ( not expired & not too far in the future ) . Return the mean of all expiry time .
fn prepare(
    time_source: &dyn TimeSource,
    pool: &mut IngressPoolImpl,
    now: Time,
    num: usize,
) -> Time {
    let mut changeset = ChangeSet::new();
    let ingress_size = 1024;
    let mut rng = rand::thread_rng();
    for i in 0..num {
        // Only 10% of them will be considered valid
        let expiry = std::time::Duration::from_millis(
            rng.gen::<u64>() % (10 * (MAX_INGRESS_TTL.as_millis() as u64)),
        );
        let ingress = SignedIngressBuilder::new()
            .method_name("provisional_create_canister_with_cycles")
            .method_payload(vec![0; ingress_size])
            .nonce(i as u64)
            .expiry_time(now + expiry)
            .canister_id(IC_00)
            .build();
        let message_id = IngressMessageId::from(&ingress);
        let attribute = IngressMessageAttribute::new(&ingress);
        let peer_id = (i % 10) as u64;
        let integrity_hash = ic_crypto::crypto_hash(ingress.binary()).get();
        pool.insert(UnvalidatedArtifact {
            message: ingress,
            peer_id: node_test_id(peer_id),
            timestamp: time_source.get_relative_time(),
        });
        changeset.push(ChangeAction::MoveToValidated((
            message_id,
            node_test_id(peer_id),
            0,
            attribute,
            integrity_hash,
        )));
    }
    pool.apply_changeset(changeset);
    assert_eq!(pool.unvalidated().size(), 0);
    assert_eq!(pool.validated().size(), num);
    now + 5 * MAX_INGRESS_TTL
}
fn prepare ( time_source : & dyn TimeSource , pool : & mut IngressPoolImpl , now : Time , num : usize , ) -> Time { let mut changeset = ChangeSet :: new ( ) ; let ingress_size = 1024 ; let mut rng = rand :: thread_rng ( ) ; for i in 0 .. num { // Only 10% of them will be considered valid let expiry = std :: time :: Duration :: from_millis ( rng . gen :: < u64 > ( ) % ( 10 * ( MAX_INGRESS_TTL . as_millis ( ) as u64 ) ) , ) ; let ingress = SignedIngressBuilder :: new ( ) . method_name ( " " ) . method_payload ( vec ! [ 0 ingress_size ] ) . nonce ( i as u64 ) . expiry_time ( now + expiry ) . canister_id ( IC_00 ) . build ( ) ; let message_id = IngressMessageId :: from ( & ingress ) ; let attribute = IngressMessageAttribute :: new ( & ingress ) ; let peer_id = ( i % 10 ) as u64 ; let integrity_hash = ic_crypto :: crypto_hash ( ingress . binary ( ) ) . get ( ) ; pool . insert ( UnvalidatedArtifact { message : ingress , peer_id : node_test_id ( peer_id ) , timestamp : time_source . get_relative_time ( ) , } ) ; changeset . push ( ChangeAction :: MoveToValidated ( ( message_id , node_test_id ( peer_id ) , 0 , attribute , integrity_hash , ) ) ) ; } pool . apply_changeset ( changeset ) ; assert_eq ! ( pool unvalidated ( ) size ( ) 0 ) ; assert_eq ! ( pool validated ( ) size ( ) num ) ; now + 5 * MAX_INGRESS_TTL }
Prepare pool with a set of ingress messages, only about 10% of them will
be considered as valid according to expiry restrictions (not expired & not
too far in the future).
Prepare pool with a set of ingress messages only about 10% of them will be considered as valid according to expiry restrictions ( not expired & not too far in the future ) .
time_source
&dyn TimeSource
pool
&mut IngressPoolImpl
now
Time
num
usize
time_source
&dyn TimeSource
pool
&mut IngressPoolImpl
now
Time
num
usize