|
9 | 9 | description: Blocktank base URL |
10 | 10 | required: true |
11 | 11 | default: 'https://api.stag0.blocktank.to/blocktank/api/v2' |
| 12 | + mempool_server: |
| 13 | + description: Mempool API base URL |
| 14 | + required: true |
| 15 | + default: 'https://mempool.bitkit.stag0.blocktank.to' |
12 | 16 | block_count: |
13 | 17 | description: Number of regtest blocks to mine |
14 | 18 | required: true |
|
20 | 24 | env: |
21 | 25 | BLOCK_COUNT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.block_count || '1' }} |
22 | 26 | BLOCKTANK_SERVER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.blocktank_server || 'https://api.stag0.blocktank.to/blocktank/api/v2' }} |
| 27 | + MEMPOOL_SERVER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.mempool_server || 'https://mempool.bitkit.stag0.blocktank.to' }} |
23 | 28 | steps: |
24 | 29 | - name: Validate params |
25 | 30 | run: | |
|
39 | 44 | echo "BLOCKTANK_SERVER is empty" >&2 |
40 | 45 | exit 1 |
41 | 46 | fi |
| 47 | + if [[ -z "${MEMPOOL_SERVER}" ]]; then |
| 48 | + echo "MEMPOOL_SERVER is empty" >&2 |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | + - name: Capture initial tip height |
| 52 | + run: | |
| 53 | + MEMPOOL_API="${MEMPOOL_SERVER%/}/api/blocks/tip/height" |
| 54 | + TIP_BEFORE=$(curl -sS "${MEMPOOL_API}" | tr -dc '0-9') |
| 55 | + if [[ -z "${TIP_BEFORE}" ]]; then |
| 56 | + echo "Failed to obtain initial block height" >&2 |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + echo "Initial tip height: ${TIP_BEFORE}" |
| 60 | + echo "TIP_BEFORE=${TIP_BEFORE}" >> "${GITHUB_ENV}" |
42 | 61 | - name: Mine regtest blocks |
43 | 62 | run: | |
44 | 63 | echo "Mining ${BLOCK_COUNT} block(s) on regtest..." |
|
47 | 66 | "${BLOCKTANK_SERVER}/regtest/chain/mine" \ |
48 | 67 | -H 'Content-Type: application/json' \ |
49 | 68 | -d "{\"count\": ${BLOCK_COUNT}}" |
| 69 | + - name: Verify new tip height |
| 70 | + run: | |
| 71 | + MEMPOOL_API="${MEMPOOL_SERVER%/}/api/blocks/tip/height" |
| 72 | + EXPECTED=$((TIP_BEFORE + BLOCK_COUNT)) |
| 73 | + echo "Waiting up to 10 seconds for tip height to reach ${EXPECTED}..." |
| 74 | + END=$((SECONDS + 10)) |
| 75 | + LAST_TIP="" |
| 76 | + while (( SECONDS < END )); do |
| 77 | + TIP_AFTER=$(curl -sS "${MEMPOOL_API}" | tr -dc '0-9') |
| 78 | + if [[ -n "${TIP_AFTER}" ]]; then |
| 79 | + LAST_TIP="${TIP_AFTER}" |
| 80 | + if (( TIP_AFTER >= EXPECTED )); then |
| 81 | + echo "New tip height: ${TIP_AFTER}" |
| 82 | + echo "Regtest height increased as expected" |
| 83 | + exit 0 |
| 84 | + fi |
| 85 | + else |
| 86 | + echo "Failed to read tip height, retrying..." |
| 87 | + fi |
| 88 | + sleep 1 |
| 89 | + done |
| 90 | + echo "Tip height did not reach expected value ${EXPECTED} (started at ${TIP_BEFORE}) within 10 seconds (last observed: ${LAST_TIP:-unknown})" >&2 |
| 91 | + exit 1 |
0 commit comments