Skip to content

Commit 04e3314

Browse files
committed
Add mempool block height tip check
1 parent 397e4c7 commit 04e3314

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/regtest-mine.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
env:
2121
BLOCK_COUNT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.block_count || '1' }}
2222
BLOCKTANK_SERVER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.blocktank_server || 'https://api.stag0.blocktank.to/blocktank/api/v2' }}
23+
MEMPOOL_API: https://mempool.bitkit.stag0.blocktank.to/api/blocks/tip/height
2324
steps:
2425
- name: Validate params
2526
run: |
@@ -39,6 +40,15 @@ jobs:
3940
echo "BLOCKTANK_SERVER is empty" >&2
4041
exit 1
4142
fi
43+
- name: Capture initial tip height
44+
run: |
45+
TIP_BEFORE=$(curl -sS "${MEMPOOL_API}" | tr -dc '0-9')
46+
if [[ -z "${TIP_BEFORE}" ]]; then
47+
echo "Failed to obtain initial block height" >&2
48+
exit 1
49+
fi
50+
echo "Initial tip height: ${TIP_BEFORE}"
51+
echo "TIP_BEFORE=${TIP_BEFORE}" >> "${GITHUB_ENV}"
4252
- name: Mine regtest blocks
4353
run: |
4454
echo "Mining ${BLOCK_COUNT} block(s) on regtest..."
@@ -47,3 +57,17 @@ jobs:
4757
"${BLOCKTANK_SERVER}/regtest/chain/mine" \
4858
-H 'Content-Type: application/json' \
4959
-d "{\"count\": ${BLOCK_COUNT}}"
60+
- name: Verify new tip height
61+
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}"
68+
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"

0 commit comments

Comments
 (0)