Skip to content

Commit 89ece35

Browse files
authored
Merge pull request #9 from IntentProof/phase3-sdk-signing-golden
Read signing golden fixtures from spec checkout
2 parents c694ea9 + 093300d commit 89ece35

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
- name: Checkout spec repository
17+
uses: actions/checkout@v4
18+
with:
19+
repository: IntentProof/intentproof-spec
20+
ref: main
21+
path: intentproof-spec
22+
23+
- name: Ensure spec sdk-signing golden checkout
24+
run: |
25+
if [[ -d intentproof-spec/golden/sdk-signing ]]; then
26+
exit 0
27+
fi
28+
git -C intentproof-spec fetch origin phase3-ecosystem-conformance
29+
git -C intentproof-spec checkout FETCH_HEAD
30+
1631
- uses: actions/setup-go@v5
1732
with:
1833
go-version: '1.25'
@@ -21,4 +36,11 @@ jobs:
2136
run: go mod verify
2237

2338
- name: Run tests and enforce coverage
39+
env:
40+
INTENTPROOF_SPEC_DIR: intentproof-spec
2441
run: bash ./scripts/run-coverage-gate.sh
42+
43+
- name: Verify sdk-signing fixtures synced with spec
44+
env:
45+
INTENTPROOF_SPEC_DIR: intentproof-spec
46+
run: bash ./scripts/check-sdk-signing-fixtures-sync.sh

intentproof/signing_golden_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@ import (
1010
"github.com/intentproof/intentproof-sdk-go/intentproof"
1111
)
1212

13+
func signingFixtureDir(t *testing.T) string {
14+
t.Helper()
15+
if specDir := strings.TrimSpace(os.Getenv("INTENTPROOF_SPEC_DIR")); specDir != "" {
16+
if !filepath.IsAbs(specDir) {
17+
specDir = filepath.Join("..", specDir)
18+
}
19+
return filepath.Join(specDir, "golden", "sdk-signing")
20+
}
21+
return filepath.Join("..", "testdata", "fixtures")
22+
}
23+
1324
func TestSigningGoldenBytes(t *testing.T) {
14-
fixtureDir := filepath.Join("..", "testdata", "fixtures")
25+
fixtureDir := signingFixtureDir(t)
1526
unsignedRaw, err := os.ReadFile(filepath.Join(fixtureDir, "signing_unsigned_event.json"))
1627
if err != nil {
1728
t.Fatal(err)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# Fail when mirrored SDK signing fixtures drift from intentproof-spec.
3+
set -euo pipefail
4+
5+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
cd "$ROOT"
7+
LOCAL="${ROOT}/testdata/fixtures"
8+
9+
spec_dir="${INTENTPROOF_SPEC_DIR:?INTENTPROOF_SPEC_DIR must point at intentproof-spec}"
10+
if [[ "$spec_dir" != /* ]]; then
11+
spec_dir="${ROOT}/${spec_dir}"
12+
fi
13+
CANONICAL="${spec_dir}/golden/sdk-signing"
14+
15+
if [[ ! -d "$CANONICAL" ]]; then
16+
echo "canonical sdk-signing fixtures not found at ${CANONICAL}" >&2
17+
exit 1
18+
fi
19+
20+
shopt -s nullglob
21+
files=("${CANONICAL}"/signing_*)
22+
if [[ ${#files[@]} -eq 0 ]]; then
23+
echo "no signing fixtures under ${CANONICAL}" >&2
24+
exit 1
25+
fi
26+
27+
fail=0
28+
for canonical in "${files[@]}"; do
29+
base="$(basename "$canonical")"
30+
local_path="${LOCAL}/${base}"
31+
if [[ ! -f "$local_path" ]]; then
32+
continue
33+
fi
34+
if ! cmp -s "$canonical" "$local_path"; then
35+
echo "sdk-signing fixture drift: ${base} differs from spec golden/sdk-signing" >&2
36+
fail=1
37+
fi
38+
done
39+
40+
if [[ "$fail" -ne 0 ]]; then
41+
exit 1
42+
fi
43+
44+
echo "PASS: sdk-signing fixture mirrors match spec golden."

0 commit comments

Comments
 (0)