Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions .github/workflows/ci.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Build
run: make build

- name: Run tests against mock handler
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project_name: kernel-bindings-tests

builds:
- id: runner
main: ./cmd/runner
binary: runner
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64

archives:
- id: runner-archive
builds:
- runner
format: tar.gz
format_overrides:
- goos: windows
format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

checksum:
disable: true

changelog:
disable: true

release:
github:
owner: stringintech
name: kernel-bindings-tests
draft: false
prerelease: auto
48 changes: 19 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
.PHONY: all build test test-single clean
.PHONY: all build test clean runner mock-handler deps lint

BUILD_DIR := build
RUNNER_BIN := $(BUILD_DIR)/runner
MOCK_HANDLER_BIN := $(BUILD_DIR)/mock-handler

all: build test

build:
@echo "Building orchestrator binary..."
mkdir -p bin
cd orchestrator && go build -o ./bin/orchestrator
@echo "Building go-handler binary..."
cd go-handler/go-bitcoinkernel && $(MAKE) build-kernel && $(MAKE) build
cd go-handler && go build -o ./bin/go-handler
@echo "Building rust-handler binary..."
cd rust-handler && cargo build --release
@echo "Build complete!"
build: runner mock-handler

test:
@echo "Running all conformance tests with go-handler..."
-./orchestrator/bin/orchestrator -handler ./go-handler/bin/go-handler -testdir testdata
@echo "Running all conformance tests with rust-handler..."
-./orchestrator/bin/orchestrator -handler ./rust-handler/target/release/rust-handler -testdir testdata
runner:
@echo "Building test runner..."
@mkdir -p $(BUILD_DIR)
go build -o $(RUNNER_BIN) ./cmd/runner

test-single:
@if [ -z "$(TEST)" ]; then \
echo "Error: TEST variable not set. Usage: make test-single TEST=testdata/chainstate_basic.json"; \
exit 1; \
fi
@echo "Running test with go-handler: $(TEST)"
./bin/orchestrator -handler ./go-handle/bin/go-handler -testfile $(TEST)
@echo "Running test with rust-handler: $(TEST)"
./bin/orchestrator -handler ./rust-handler/target/release/rust-handler -testfile $(TEST)
mock-handler:
@echo "Building mock handler..."
@mkdir -p $(BUILD_DIR)
go build -o $(MOCK_HANDLER_BIN) ./cmd/mock-handler

test:
@echo "Running conformance tests with mock handler..."
$(RUNNER_BIN) -handler $(MOCK_HANDLER_BIN)

clean:
@echo "Cleaning build artifacts..."
cd go-handler/go-bitcoinkernel && $(MAKE) clean
cd orchestrator && go clean && rm -rf build
cd go-handler && go clean && rm -rf build
cd rust-handler && cargo clean
rm -rf $(BUILD_DIR)
51 changes: 18 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bitcoin Kernel Binding Conformance Tests

This directory contains a language-agnostic conformance testing framework for Bitcoin Kernel bindings.
This repository contains a language-agnostic conformance testing framework for Bitcoin Kernel bindings.

## ⚠️ Work in Progress

Expand All @@ -15,53 +15,38 @@ The framework ensures that all language bindings (Go, Python, Rust, etc.) behave

```
┌─────────────┐ ┌──────────────────┐
Orchestrator│────────▶│ Handler Binary │
│ (Go Test │ stdin │ (Go/Rust/etc) │
Runner) │◀────────│ │
Test Runner │────────▶│ Handler Binary │
│ (Go CLI) │ stdin │ (Go/Rust/etc) │
│◀────────│ │
└─────────────┘ stdout └──────────────────┘
│ │
│ │
▼ ▼
┌─────────┐ ┌────────────────┐
│ Test │ │ Binding API │
│ Cases │ └────────────────┘
│ (JSON) │
│ (JSON) │
└─────────┘
```

1. [**Orchestrator**](./orchestrator): Spawns handler binary, sends test requests, validates responses
2. **Handler Binary**: Implements protocol, calls binding API, returns results
- [Go handler](./go-handler) for the [Go binding](https://github.com/stringintech/go-bitcoinkernel)
- [Rust handler](./rust-handler) for the [Rust binding](https://github.com/TheCharlatan/rust-bitcoinkernel)
3. [**Test Cases**](./testdata): JSON files defining requests and expected responses

## Getting Started

### Cloning

Clone the repository with submodules:

```bash
git clone --recurse-submodules https://github.com/stringintech/kernel-bindings-spec.git
```
**Note:** go-handler currently depends on go-bitcoinkernel via a submodule.
**This repository contains:**
1. [**Test Runner**](./cmd/runner/main.go): Spawns handler binary, sends test requests via stdin, validates responses from stdout
2. [**Test Cases**](./testdata): JSON files defining requests and expected responses
3. [**Mock Handler**](./cmd/mock-handler/main.go): Validates the runner by echoing expected responses from test cases

**Handler binaries** are not hosted in this repository. They must be implemented separately and should:
- Implement the JSON protocol for communication with the test runner
- Call the binding API to execute operations
- Pin to a specific version/tag of this test repository

### Building
## Getting Started

Use the provided Makefile to build the project:
Build and test against the mock handler:

```bash
# Build everything!
# Build both runner and mock handler
make build
```

### Running Tests

```bash
# Run all conformance tests with both Go and Rust handlers
# Run tests against the mock handler
make test

# Run a specific test file with both Go and Rust handlers
make test-single TEST=testdata/chainstate_basic.json
```
```
Loading
Loading