fn run_gossip_topo<F>(num: usize, topo: F)
where
    F: Fn(&Vec<(Arc<ClusterInfo>, GossipService, UdpSocket)>),
{
    let exit = Arc::new(AtomicBool::new(false));
    let listen: Vec<_> = (0..num).map(|_| test_node(&exit)).collect();
    topo(&listen);
    let mut done = true;
    for i in 0..(num * 32) {
        done = true;
        let total: usize = listen.iter().map(|v| v.0.gossip_peers().len()).sum();
        if (total + num) * 10 > num * num * 9 {
            done = true;
            break;
        } else {
            trace!("not converged {} {} {}", i, total + num, num * num);
        }
        sleep(Duration::new(1, 0));
    }
    exit.store(true, Ordering::Relaxed);
    for (_, dr, _) in listen {
        dr.join().unwrap();
    }
    assert!(done);
}
/// Test that the network converges.
/// Run until every node in the network has a full ContactInfo set.
/// Check that nodes stop sending updates after all the ContactInfo has been shared.
/// tests that actually use this function are below
Test that the network converges.
Run until every node in the network has a full ContactInfo set.
Check that nodes stop sending updates after all the ContactInfo has been shared.
tests that actually use this function are below
Test that the network converges . Run until every node in the network has a full ContactInfo set . Check that nodes stop sending updates after all the ContactInfo has been shared . tests that actually use this function are below
fn run_gossip_topo<F>(num: usize, topo: F)
where
    F: Fn(&Vec<(Arc<ClusterInfo>, GossipService, UdpSocket)>),
{
    let exit = Arc::new(AtomicBool::new(false));
    let listen: Vec<_> = (0..num).map(|_| test_node(&exit)).collect();
    topo(&listen);
    let mut done = true;
    for i in 0..(num * 32) {
        done = true;
        let total: usize = listen.iter().map(|v| v.0.gossip_peers().len()).sum();
        if (total + num) * 10 > num * num * 9 {
            done = true;
            break;
        } else {
            trace!("not converged {} {} {}", i, total + num, num * num);
        }
        sleep(Duration::new(1, 0));
    }
    exit.store(true, Ordering::Relaxed);
    for (_, dr, _) in listen {
        dr.join().unwrap();
    }
    assert!(done);
}
fn run_gossip_topo < F > ( num : usize , topo : F ) where F : Fn ( & Vec < ( Arc < ClusterInfo > , GossipService , UdpSocket ) > ) , { let exit = Arc :: new ( AtomicBool :: new ( false ) ) ; let listen : Vec < _ > = ( 0 .. num ) . map ( | _ | test_node ( & exit ) ) . collect ( ) ; topo ( & listen ) ; let mut done = true ; for i in 0 .. ( num * 32 ) { done = true ; let total : usize = listen . iter ( ) . map ( | v | v . 0 . gossip_peers ( ) . len ( ) ) . sum ( ) ; if ( total + num ) * 10 > num * num * 9 { done = true ; break ; } else { trace ! ( " " i total num num num ) ; } sleep ( Duration :: new ( 1 , 0 ) ) ; } exit . store ( true , Ordering :: Relaxed ) ; for ( _ , dr , _ ) in listen { dr . join ( ) . unwrap ( ) ; } assert ! ( done ) ; }
Test that the network converges.
Test that the network converges .
num
usize
topo
F