Skip to content

Commit 4db8aec

Browse files
committed
Waiting up to 10 seconds for tip height
1 parent 04e3314 commit 4db8aec

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

.github/workflows/regtest-mine.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,23 @@ jobs:
5959
-d "{\"count\": ${BLOCK_COUNT}}"
6060
- name: Verify new tip height
6161
run: |
62-
TIP_AFTER=$(curl -sS "${MEMPOOL_API}" | tr -dc '0-9')
63-
if [[ -z "${TIP_AFTER}" ]]; then
64-
echo "Failed to obtain post-mining block height" >&2
65-
exit 1
66-
fi
67-
echo "New tip height: ${TIP_AFTER}"
6862
EXPECTED=$((TIP_BEFORE + BLOCK_COUNT))
69-
if (( TIP_AFTER < EXPECTED )); then
70-
echo "Tip height ${TIP_AFTER} is less than expected ${EXPECTED}" >&2
71-
exit 1
72-
fi
73-
echo "Regtest height increased as expected"
63+
echo "Waiting up to 10 seconds for tip height to reach ${EXPECTED}..."
64+
END=$((SECONDS + 10))
65+
LAST_TIP=""
66+
while (( SECONDS < END )); do
67+
TIP_AFTER=$(curl -sS "${MEMPOOL_API}" | tr -dc '0-9')
68+
if [[ -n "${TIP_AFTER}" ]]; then
69+
LAST_TIP="${TIP_AFTER}"
70+
if (( TIP_AFTER >= EXPECTED )); then
71+
echo "New tip height: ${TIP_AFTER}"
72+
echo "Regtest height increased as expected"
73+
exit 0
74+
fi
75+
else
76+
echo "Failed to read tip height, retrying..."
77+
fi
78+
sleep 1
79+
done
80+
echo "Tip height did not reach expected value ${EXPECTED} within 10 seconds (last observed: ${LAST_TIP:-unknown})" >&2
81+
exit 1

0 commit comments

Comments
 (0)