message: Factor out `is_in_era` predicate
diff: @@ -160,23 +160,10 @@ fn era_ids(runner: &Runner<ConditionCheckReactor<validator::Reactor>>) -> HashSe
  .collect()
  }
  -#[tokio::test]
  -async fn run_validator_network() {
  - testing::init_logging();
  -
  - let mut rng = crate::new_rng();
  -
  - // Instantiate a new chain with a fixed size.
  - const NETWORK_SIZE: usize = 5;
  - let mut chain = TestChain::new(&mut rng, NETWORK_SIZE);
  -
  - let mut net = chain
  - .create_initialized_network(&mut rng)
  - .await
  - .expect("network initialization failed");
  -
  - let is_in_era = |era_num| {
  +/// Given an era number, return a predicate to check if all of the nodes are in that specified era.
  +fn is_in_era(era_num: usize) -> impl Fn(&Nodes) -> bool {
  move |nodes: &Nodes| {
  + // check ee's era_validators against consensus' validators
  let first_node = nodes.values().next().expect("need at least one node");
  // Get a list of eras from the first node.
  @@ -193,7 +180,22 @@ async fn run_validator_network() {
  .map(era_ids)
  .all(|eras| eras == expected_eras)
  }
  - };
  +}
  +
  +#[tokio::test]
  +async fn run_validator_network() {
  + testing::init_logging();
  +
  + let mut rng = crate::new_rng();
  +
  + // Instantiate a new chain with a fixed size.
  + const NETWORK_SIZE: usize = 5;
  + let mut chain = TestChain::new(&mut rng, NETWORK_SIZE);
  +
  + let mut net = chain
  + .create_initialized_network(&mut rng)
  + .await
  + .expect("network initialization failed");
  // Wait for all nodes to agree on one era.
  net.settle_on(&mut rng, is_in_era(1), Duration::from_secs(90))
  @@ -227,27 +229,6 @@ async fn run_equivocator_network() {
  .await
  .expect("network initialization failed");
  - let is_in_era = |era_num| {
  - move |nodes: &Nodes| {
  - // check ee's era_validators against consensus' validators
  - let first_node = nodes.values().next().expect("need at least one node");
  -
  - // Get a list of eras from the first node.
  - let expected_eras = era_ids(&first_node);
  -
  - // Return if not in expected era yet.
  - if expected_eras.len() <= era_num {
  - return false;
  - }
  -
  - // Ensure eras are all the same for all other nodes.
  - nodes
  - .values()
  - .map(era_ids)
  - .all(|eras| eras == expected_eras)
  - }
  - };
  -
  info!("Waiting for Era 1 to end");
  net.settle_on(&mut rng, is_in_era(1), Duration::from_secs(600))
  .await;
  