#!/usr/bin/env bash
# WEIGHT=10
# CHECK: C12 singleflight dedup for getEpochSwitchInfo (PR #423 regressed)
# REF: golang.org/x/sync/singleflight should be imported and used
set -e
engine="$PATIENT/consensus/XDPoS/engines/engine_v2/engine.go"
[[ -f "$engine" ]] || exit 1
# Pass: singleflight package is imported AND used in epoch-switch info lookup.
grep -qE '"golang\.org/x/sync/singleflight"' "$engine" || exit 1
# Pass: a singleflight.Group field exists on the engine struct.
grep -qE 'singleflight\.Group' "$engine" || exit 1
# Pass: an .Do() call exists in/near getEpochSwitchInfo (line range 1100-1300 typical).
grep -qE '\.Do\(' "$engine"
