<s> from hydrachain . consensus . manager import ConsensusManager <EOL> from hydrachain . consensus . simulation import Network , assert_heightdistance , assert_maxrounds <EOL> def test_resyncing_of_peers ( ) : <EOL> network = Network ( num_nodes = <NUM_LIT:10> , simenv = True ) <EOL> network . nodes [ <NUM_LIT:0> ] . isactive = False <EOL> network . connect_nodes ( ) <EOL> network . normvariate_base_latencies ( ) <EOL> network . start ( ) <EOL> network . run ( <NUM_LIT:5> ) <EOL> network . nodes [ <NUM_LIT:0> ] . isactive = True <EOL> network . connect_nodes ( ) <EOL> network . normvariate_base_latencies ( ) <EOL> network . start ( ) <EOL> network . run ( <NUM_LIT:3> ) <EOL> r = network . check_consistency ( ) <EOL> assert_heightdistance ( r ) <EOL> def test_successive_joining ( ) : <EOL> network = Network ( num_nodes = <NUM_LIT:10> , simenv = True ) <EOL> for n in network . nodes : <EOL> n . isactive = False <EOL> for n in network . nodes : <EOL> n . isactive = True <EOL> network . connect_nodes ( ) <EOL> network . start ( ) <EOL> network . run ( <NUM_LIT:2> ) <EOL> network . run ( <NUM_LIT:2> ) <EOL> r = network . check_consistency ( ) <EOL> assert_heightdistance ( r ) <EOL> def test_broadcasting ( ) : <EOL> network = Network ( num_nodes = <NUM_LIT:10> , simenv = True ) <EOL> orig_timeout = ConsensusManager . round_timeout <EOL> for i , n in enumerate ( network . nodes ) : <EOL> if i + <NUM_LIT:1> < len ( network . nodes ) : <EOL> o = network . nodes [ i + <NUM_LIT:1> ] <EOL> else : <EOL> o = network . nodes [ <NUM_LIT:0> ] <EOL> n . connect_app ( o ) <EOL> network . normvariate_base_latencies ( ) <EOL> network . start ( ) <EOL> network . run ( <NUM_LIT:10> ) <EOL> ConsensusManager . round_timeout = orig_timeout <EOL> r = network . check_consistency ( ) <EOL> assert_maxrounds ( r ) <EOL> assert_heightdistance ( r ) </s>
