fix tests
This commit is contained in:
		
							parent
							
								
									d128c20dc2
								
							
						
					
					
						commit
						dbf82c2e98
					
				@ -647,7 +647,7 @@ mod tests {
 | 
				
			|||||||
		let engine = spec.engine;
 | 
							let engine = spec.engine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		let mut header = Header::default();
 | 
							let mut header = Header::default();
 | 
				
			||||||
		let proposer = insert_and_unlock(&tap, "0");
 | 
							let proposer = insert_and_unlock(&tap, "1");
 | 
				
			||||||
		header.set_author(proposer);
 | 
							header.set_author(proposer);
 | 
				
			||||||
		let mut seal = proposal_seal(&tap, &header, 0);
 | 
							let mut seal = proposal_seal(&tap, &header, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -687,6 +687,7 @@ mod tests {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	#[test]
 | 
						#[test]
 | 
				
			||||||
	fn step_transitioning() {
 | 
						fn step_transitioning() {
 | 
				
			||||||
 | 
							::env_logger::init().unwrap();
 | 
				
			||||||
		let (spec, tap) = setup();
 | 
							let (spec, tap) = setup();
 | 
				
			||||||
		let engine = spec.engine.clone();
 | 
							let engine = spec.engine.clone();
 | 
				
			||||||
		let mut db_result = get_temp_state_db();
 | 
							let mut db_result = get_temp_state_db();
 | 
				
			||||||
@ -717,11 +718,11 @@ mod tests {
 | 
				
			|||||||
		vote(&engine, |mh| tap.sign(v0, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
 | 
							vote(&engine, |mh| tap.sign(v0, None, mh).ok().map(H520::from), h, r, Step::Precommit, proposal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Wait a bit for async stuff.
 | 
							// Wait a bit for async stuff.
 | 
				
			||||||
		::std::thread::sleep(::std::time::Duration::from_millis(500));
 | 
							::std::thread::sleep(::std::time::Duration::from_millis(50));
 | 
				
			||||||
		seal[2] = precommit_signatures(&tap, h, r, Some(b.header().bare_hash()), v0, v1);
 | 
							seal[2] = precommit_signatures(&tap, h, r, Some(b.header().bare_hash()), v0, v1);
 | 
				
			||||||
		let first = test_io.received.read()[5] == ClientIoMessage::SubmitSeal(proposal.unwrap(), seal.clone());
 | 
							let first = test_io.received.read().contains(&ClientIoMessage::SubmitSeal(proposal.unwrap(), seal.clone()));
 | 
				
			||||||
		seal[2] = precommit_signatures(&tap, h, r, Some(b.header().bare_hash()), v1, v0);
 | 
							seal[2] = precommit_signatures(&tap, h, r, Some(b.header().bare_hash()), v1, v0);
 | 
				
			||||||
		let second = test_io.received.read()[5] == ClientIoMessage::SubmitSeal(proposal.unwrap(), seal);
 | 
							let second = test_io.received.read().contains(&ClientIoMessage::SubmitSeal(proposal.unwrap(), seal));
 | 
				
			||||||
		assert!(first ^ second);
 | 
							assert!(first ^ second);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -49,9 +49,9 @@ impl Default for TendermintTimeouts {
 | 
				
			|||||||
	fn default() -> Self {
 | 
						fn default() -> Self {
 | 
				
			||||||
		TendermintTimeouts {
 | 
							TendermintTimeouts {
 | 
				
			||||||
			propose: Duration::milliseconds(2000),
 | 
								propose: Duration::milliseconds(2000),
 | 
				
			||||||
			prevote: Duration::milliseconds(1000),
 | 
								prevote: Duration::milliseconds(2000),
 | 
				
			||||||
			precommit: Duration::milliseconds(1000),
 | 
								precommit: Duration::milliseconds(2000),
 | 
				
			||||||
			commit: Duration::milliseconds(1000)
 | 
								commit: Duration::milliseconds(2000)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -99,8 +99,7 @@ impl IoHandler<Step> for TransitionHandler {
 | 
				
			|||||||
					Step::Precommit => {
 | 
										Step::Precommit => {
 | 
				
			||||||
						trace!(target: "poa", "timeout: Precommit timeout without enough votes.");
 | 
											trace!(target: "poa", "timeout: Precommit timeout without enough votes.");
 | 
				
			||||||
						set_timeout(io, engine.our_params.timeouts.propose);
 | 
											set_timeout(io, engine.our_params.timeouts.propose);
 | 
				
			||||||
						engine.increment_round(1);
 | 
											Some(Step::Precommit)
 | 
				
			||||||
						Some(Step::Propose)
 | 
					 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					Step::Commit => {
 | 
										Step::Commit => {
 | 
				
			||||||
						trace!(target: "poa", "timeout: Commit timeout.");
 | 
											trace!(target: "poa", "timeout: Commit timeout.");
 | 
				
			||||||
@ -108,7 +107,6 @@ impl IoHandler<Step> for TransitionHandler {
 | 
				
			|||||||
						engine.reset_round();
 | 
											engine.reset_round();
 | 
				
			||||||
						Some(Step::Propose)
 | 
											Some(Step::Propose)
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					_ => None,
 | 
					 | 
				
			||||||
				};
 | 
									};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if let Some(step) = next_step {
 | 
									if let Some(step) = next_step {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user