|
| 1 | +#!/usr/bin/env bash |
| 2 | +# G3a — DASH populated block production (CI required-gate entrypoint). |
| 3 | +# Default arm (CI-runner, network-free): the DashG3Assembled.* + DashBlockProducer.* |
| 4 | +# gtest suites — c2pool-dash assembles a POPULATED block (coinbase DIP masternode |
| 5 | +# split + >=3 diverse non-witness payload txs), X11-mines a winning nonce, serializes |
| 6 | +# it, and the won block reaches the network on BOTH paths (embedded P2P + submitblock). |
| 7 | +# Optional live arm (opt-in when DASH_RPC_PASS + DASH_RPC_AUTH are set): additionally |
| 8 | +# drives scripts/dash_g3a_populated_block_regtest.sh against an isolated regtest dashd |
| 9 | +# for a real end-to-end populated block via the submitblock RPC arm. |
| 10 | +# Deterministic: exit 0 = pass; nonzero = failure / hollow run. Fenced: tests/gates/ |
| 11 | +# entrypoint over existing DASH targets — no consensus / shared-base / build.yml / CMake. |
| 12 | +set -euo pipefail |
| 13 | + |
| 14 | +GATE="G3a dash-populated-block-production" |
| 15 | +TEST_REGEX='^(DashG3Assembled|DashBlockProducer)\.' |
| 16 | +TARGETS=(test_dash_g3_assembled test_dash_block_producer) |
| 17 | + |
| 18 | +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 19 | +BUILD_DIR="${BUILD_DIR:-$REPO_ROOT/build}" |
| 20 | + |
| 21 | +# 1. Ensure the targets exist (configure+build only if the CI cache is cold). |
| 22 | +if [ ! -f "$BUILD_DIR/CMakeCache.txt" ]; then |
| 23 | + echo "[$GATE] no build dir at $BUILD_DIR — configuring (conan + cmake)" |
| 24 | + conan install "$REPO_ROOT" --build=missing --output-folder="$BUILD_DIR" --settings=build_type=Release |
| 25 | + cmake -S "$REPO_ROOT" -B "$BUILD_DIR" \ |
| 26 | + -DCMAKE_TOOLCHAIN_FILE="$BUILD_DIR/conan_toolchain.cmake" \ |
| 27 | + -DCMAKE_BUILD_TYPE=Release |
| 28 | +fi |
| 29 | +cmake --build "$BUILD_DIR" --target "${TARGETS[@]}" -j"$(nproc)" |
| 30 | + |
| 31 | +# 2. Run from build/ and capture (false-green trap: wrong CWD prints |
| 32 | +# "No tests were found!!!" and EXITS 0). |
| 33 | +set +e |
| 34 | +OUT="$(cd "$BUILD_DIR" && ctest -R "$TEST_REGEX" --output-on-failure 2>&1)" |
| 35 | +RC=$? |
| 36 | +set -e |
| 37 | +echo "$OUT" |
| 38 | + |
| 39 | +# 3. False-green guard: demand a positive test count actually ran. |
| 40 | +if grep -q "No tests were found" <<<"$OUT"; then |
| 41 | + echo "[$GATE] FAIL — hollow run: 0 tests matched $TEST_REGEX" >&2 |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | +N="$(grep -oE 'out of [0-9]+' <<<"$OUT" | grep -oE '[0-9]+' | tail -1)" |
| 45 | +if [ -z "${N:-}" ] || [ "$N" -lt 1 ]; then |
| 46 | + echo "[$GATE] FAIL — no positive test count parsed" >&2 |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | +if [ "$RC" -ne 0 ]; then |
| 50 | + echo "[$GATE] FAIL — ctest exit $RC ($N tests)" >&2 |
| 51 | + exit "$RC" |
| 52 | +fi |
| 53 | +echo "[$GATE] PASS (CI arm) — $N assembled-block / producer assertions green" |
| 54 | + |
| 55 | +# 4. Optional live regtest arm — only when an isolated dashd is wired in via env. |
| 56 | +if [ -n "${DASH_RPC_PASS:-}" ] && [ -n "${DASH_RPC_AUTH:-}" ]; then |
| 57 | + echo "[$GATE] live arm: driving scripts/dash_g3a_populated_block_regtest.sh" |
| 58 | + "$REPO_ROOT/scripts/dash_g3a_populated_block_regtest.sh" |
| 59 | + echo "[$GATE] PASS (live arm) — populated regtest block proven via c2pool-dash submitblock" |
| 60 | +else |
| 61 | + echo "[$GATE] live regtest arm SKIPPED (set DASH_RPC_PASS + DASH_RPC_AUTH to enable)" |
| 62 | +fi |
0 commit comments