diff --git a/ethcore/src/engines/authority_round.rs b/ethcore/src/engines/authority_round.rs
index 4e7d564fe..57bb513ae 100644
--- a/ethcore/src/engines/authority_round.rs
+++ b/ethcore/src/engines/authority_round.rs
@@ -100,6 +100,7 @@ impl AsMillis for Duration {
impl AuthorityRound {
/// Create a new instance of AuthorityRound engine.
pub fn new(params: CommonParams, our_params: AuthorityRoundParams, builtins: BTreeMap
) -> Result, Error> {
+ let should_timeout = our_params.start_step.is_none();
let initial_step = our_params.start_step.unwrap_or_else(|| (unix_now().as_secs() / our_params.step_duration.as_secs())) as usize;
let engine = Arc::new(
AuthorityRound {
@@ -113,8 +114,11 @@ impl AuthorityRound {
account_provider: Mutex::new(None),
password: RwLock::new(None),
});
- let handler = TransitionHandler { engine: Arc::downgrade(&engine) };
- try!(engine.transition_service.register_handler(Arc::new(handler)));
+ // Do not initialize timeouts for tests.
+ if should_timeout {
+ let handler = TransitionHandler { engine: Arc::downgrade(&engine) };
+ try!(engine.transition_service.register_handler(Arc::new(handler)));
+ }
Ok(engine)
}
diff --git a/sync/src/tests/consensus.rs b/sync/src/tests/consensus.rs
index c1fa8fce7..e1f73d066 100644
--- a/sync/src/tests/consensus.rs
+++ b/sync/src/tests/consensus.rs
@@ -82,12 +82,14 @@ fn authority_round() {
net.sync();
// Trigger block proposal
net.peer(0).chain.miner().import_own_transaction(&*net.peer(0).chain, new_tx(s0.secret(), 0.into())).unwrap();
+ net.peer(1).chain.miner().import_own_transaction(&*net.peer(1).chain, new_tx(s1.secret(), 0.into())).unwrap();
// Sync a block
net.sync();
assert_eq!(net.peer(0).chain.chain_info().best_block_number, 1);
assert_eq!(net.peer(1).chain.chain_info().best_block_number, 1);
- net.peer(1).chain.miner().import_own_transaction(&*net.peer(1).chain, new_tx(s1.secret(), 0.into())).unwrap();
+ net.peer(0).chain.miner().import_own_transaction(&*net.peer(0).chain, new_tx(s0.secret(), 1.into())).unwrap();
+ net.peer(1).chain.miner().import_own_transaction(&*net.peer(1).chain, new_tx(s1.secret(), 1.into())).unwrap();
// Move to next proposer step
net.peer(0).chain.engine().step();
net.peer(1).chain.engine().step();
@@ -96,14 +98,17 @@ fn authority_round() {
assert_eq!(net.peer(1).chain.chain_info().best_block_number, 2);
// Fork the network
- net.peer(0).chain.miner().import_own_transaction(&*net.peer(0).chain, new_tx(s0.secret(), 1.into())).unwrap();
+ net.peer(0).chain.miner().import_own_transaction(&*net.peer(0).chain, new_tx(s0.secret(), 2.into())).unwrap();
+ net.peer(1).chain.miner().import_own_transaction(&*net.peer(1).chain, new_tx(s1.secret(), 2.into())).unwrap();
net.peer(0).chain.engine().step();
net.peer(1).chain.engine().step();
- assert_eq!(net.peer(0).chain.chain_info().best_block_number, 3);
- net.peer(1).chain.miner().import_own_transaction(&*net.peer(1).chain, new_tx(s1.secret(), 1.into())).unwrap();
net.peer(0).chain.engine().step();
net.peer(1).chain.engine().step();
- assert_eq!(net.peer(1).chain.chain_info().best_block_number, 3);
+ let ci0 = net.peer(0).chain.chain_info();
+ let ci1 = net.peer(1).chain.chain_info();
+ assert_eq!(ci0.best_block_number, 3);
+ assert_eq!(ci1.best_block_number, 3);
+ assert!(ci0.best_block_hash != ci1.best_block_hash);
// Reorg to the correct one.
net.sync();
let ci0 = net.peer(0).chain.chain_info();