Skip to content

Commit ee3c7d8

Browse files
committed
bch: add G3a populated-block CI required-gate entrypoint
Mirror the DASH tests/gates/ G3a pattern for BCH: a fenced, deterministic gate over the existing COIN_BCH in-process CHECK-harnesses so G3a counts as a named CI required-gate (network-free CI arm) with an opt-in live regtest arm. CI arm (network-free): ctest over bch_embedded_daemon_assembly_test (block assembled from the real EmbeddedCoinNode seam), bch_embedded_block_broadcast_test (won block reaches network on both P2P + submitblock paths), bch_block_ordering_test (CTOR), bch_cashtokens_transparency_test (FT/NFT transparent carry), bch_coinbase_kat_bytevector_test (no-witness SHA256d coinbase). False-green guard demands a positive count AND the full expected set matched. Live arm (opt-in via BCH_RPC_PASS + BCH_RPC_AUTH): drives the already-merged scripts/bch_g3a_populated_block_regtest.py against an isolated regtest BCHN for the full A1-A7 attestation. Fenced: tests/gates/ entrypoint over existing targets; no consensus, shared-base, build.yml, CMake, or other-coin surface.
1 parent 3b5267d commit ee3c7d8

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
# G3a — BCH populated block production (CI required-gate entrypoint).
3+
# Default arm (CI-runner, network-free): the c2pool-bch in-process CHECK-harnesses
4+
# that together prove POPULATED-block production without a live BCHN node —
5+
# bch_embedded_daemon_assembly_test : EmbeddedDaemon assembles the block from its
6+
# own real EmbeddedCoinNode seam (coinbase +
7+
# ABLA-bounded template), embedded-primary.
8+
# bch_embedded_block_broadcast_test : the won block reaches the network on BOTH
9+
# paths (embedded P2P + submitblock fallback).
10+
# bch_block_ordering_test : CTOR canonical tx ordering (A3).
11+
# bch_cashtokens_transparency_test : CashTokens FT/NFT genesis+transfer carried
12+
# transparently through the template (A5).
13+
# bch_coinbase_kat_bytevector_test : coinbase byte-vector KAT — no witness
14+
# commitment, standalone SHA256d (A1/A2).
15+
# Optional live arm (opt-in when BCH_RPC_PASS + BCH_RPC_AUTH are set): additionally
16+
# drives scripts/bch_g3a_populated_block_regtest.py against an isolated regtest BCHN
17+
# (v29.0.0, --disable-wallet) for a real end-to-end populated block — the full A1–A7
18+
# attestation (produced block 5fa6e22b…; CashTokens FT/NFT/transfer, P2SH32, CTOR,
19+
# merkle, no-witness, 30-in consolidation) via the submitblock RPC arm.
20+
# Deterministic: exit 0 = pass; nonzero = failure / hollow run. Fenced: tests/gates/
21+
# entrypoint over existing COIN_BCH targets — no consensus / shared-base / build.yml /
22+
# CMake / other-coin surface.
23+
set -euo pipefail
24+
25+
GATE="G3a bch-populated-block-production"
26+
TEST_REGEX='^bch_(embedded_daemon_assembly_test|embedded_block_broadcast_test|block_ordering_test|cashtokens_transparency_test|coinbase_kat_bytevector_test)$'
27+
TARGETS=(bch_embedded_daemon_assembly_test bch_embedded_block_broadcast_test \
28+
bch_block_ordering_test bch_cashtokens_transparency_test \
29+
bch_coinbase_kat_bytevector_test)
30+
31+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
32+
# COIN_BCH targets compile ONLY under -DCOIN_BCH=ON, so default to the CI build_bch
33+
# tree; override BUILD_DIR to reuse a warm cache.
34+
BUILD_DIR="${BUILD_DIR:-$REPO_ROOT/build_bch}"
35+
36+
# 1. Ensure the targets exist (configure+build only if the CI cache is cold).
37+
if [ ! -f "$BUILD_DIR/CMakeCache.txt" ]; then
38+
echo "[$GATE] no build dir at $BUILD_DIR — configuring (conan + cmake -DCOIN_BCH=ON)"
39+
conan install "$REPO_ROOT" --build=missing --output-folder="$BUILD_DIR" --settings=build_type=Release
40+
cmake -S "$REPO_ROOT" -B "$BUILD_DIR" \
41+
-DCMAKE_TOOLCHAIN_FILE="$BUILD_DIR/conan_toolchain.cmake" \
42+
-DCMAKE_BUILD_TYPE=Release \
43+
-DCOIN_BCH=ON
44+
fi
45+
cmake --build "$BUILD_DIR" --target "${TARGETS[@]}" -j"$(nproc)"
46+
47+
# 2. Run from build/ and capture (false-green trap: wrong CWD prints
48+
# "No tests were found!!!" and EXITS 0).
49+
set +e
50+
OUT="$(cd "$BUILD_DIR" && ctest -R "$TEST_REGEX" --output-on-failure 2>&1)"
51+
RC=$?
52+
set -e
53+
echo "$OUT"
54+
55+
# 3. False-green guard: demand a positive test count actually ran, and that the
56+
# full expected set matched (a partial regex miss must not read as green).
57+
if grep -q "No tests were found" <<<"$OUT"; then
58+
echo "[$GATE] FAIL — hollow run: 0 tests matched $TEST_REGEX" >&2
59+
exit 1
60+
fi
61+
N="$(grep -oE 'out of [0-9]+' <<<"$OUT" | grep -oE '[0-9]+' | tail -1)"
62+
if [ -z "${N:-}" ] || [ "$N" -lt "${#TARGETS[@]}" ]; then
63+
echo "[$GATE] FAIL — expected ${#TARGETS[@]} tests, matched ${N:-0}" >&2
64+
exit 1
65+
fi
66+
if [ "$RC" -ne 0 ]; then
67+
echo "[$GATE] FAIL — ctest exit $RC ($N tests)" >&2
68+
exit "$RC"
69+
fi
70+
echo "[$GATE] PASS (CI arm) — $N populated-block assembly / broadcast / CTOR / CashTokens / coinbase-KAT assertions green"
71+
72+
# 4. Optional live regtest arm — only when an isolated BCHN is wired in via env.
73+
if [ -n "${BCH_RPC_PASS:-}" ] && [ -n "${BCH_RPC_AUTH:-}" ]; then
74+
echo "[$GATE] live arm: driving scripts/bch_g3a_populated_block_regtest.py"
75+
python3 "$REPO_ROOT/scripts/bch_g3a_populated_block_regtest.py"
76+
echo "[$GATE] PASS (live arm) — populated regtest block proven via isolated BCHN submitblock (A1–A7)"
77+
else
78+
echo "[$GATE] live regtest arm SKIPPED (set BCH_RPC_PASS + BCH_RPC_AUTH to enable)"
79+
fi

0 commit comments

Comments
 (0)