message: add logging messages for equiv check; move is_trusted_validator & assert_eviction to common
diff: @@ -341,12 +341,16 @@ function assert_no_equivocators_logs() {
  for i in $(seq 1 $(get_count_of_nodes)); do
  # true is because grep exits 1 on no match
  LOGS=$(cat "$NCTL"/assets/net-1/nodes/node-"$i"/logs/stdout.log 2>/dev/null | grep -w 'validator equivocated') || true
  + log "... checking node-$i's log"
  if [ ! -z "$LOGS" ]; then
  log "$(echo $LOGS)"
  - log "Fail: Equivocator(s) found!"
  + log "ERROR: Equivocator(s) found!"
  exit 1
  + else
  + log "... No Equivocator(s) found! [expected]"
  fi
  done
  + log "Finished Equivocator(s) search successfully!"
  }
  function do_submit_auction_bids()
  @@ -382,3 +386,42 @@ function assert_same_era() {
  exit 1
  fi
  }
  +
  +# Checks that the current era + 1 contains a nodes
  +# public key hex
  +function is_trusted_validator() {
  + local NODE_ID=${1}
  + local HEX=$(get_node_public_key_hex_extended "$NODE_ID")
  + local ERA=$(check_current_era)
  + # Plus 1 to avoid query issue if era switches mid run
  + local ERA_PLUS_1=$(expr $ERA + 1)
  + # note: tonumber is a must here to prevent jq from being too smart.
  + # The jq arg 'era' is set to $ERA_PLUS_1. The query looks to find that
  + # the validator is removed from era_validators list. We grep for
  + # the public_key_hex to see if the validator is still listed and return
  + # the exit code to check success.
  + nctl-view-chain-auction-info | jq --arg era "$ERA_PLUS_1" '.auction_state.era_validators[] | select(.era_id == ($era | tonumber))' | grep -q "$HEX"
  + return $?
  +}
  +
  +function assert_eviction() {
  + local NODE_ID=${1}
  + local SYNC_TIMEOUT_SEC=${2:-"300"}
  + local WAIT_TIME_SEC='0'
  +
  + log_step "Checking for evicted node-$NODE_ID..."
  + while [ "$WAIT_TIME_SEC" != "$SYNC_TIMEOUT_SEC" ]; do
  + if ( ! is_trusted_validator "$NODE_ID" ); then
  + log "validator node-$NODE_ID was ejected! [expected]"
  + break
  + fi
  +
  + WAIT_TIME_SEC=$((WAIT_TIME_SEC + 1))
  +
  + if [ "$WAIT_TIME_SEC" = "$SYNC_TIMEOUT_SEC" ]; then
  + log "ERROR: Time out. Failed to confirm node-$NODE_ID as evicted validator in $SYNC_TIMEOUT_SEC seconds."
  + exit 1
  + fi
  + sleep 1
  + done
  +}
  