Skip to content
Draft
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
61 changes: 61 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,68 @@
vapp_name: "vnd-bitcoin"
test_dirs_json: '["apps/bitcoin/bip388","apps/bitcoin/common","apps/bitcoin/app"]'

# bip388 Python port tests
test_bip388_python:
name: bip388 Python tests
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run tests
working-directory: apps/bitcoin/bip388/python
run: python -m unittest discover tests

# bip388 C port tests (regular build + AddressSanitizer/UBSan build)
test_bip388_c:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +330 to +344
name: bip388 C tests
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Set up Python (codegen tooling)
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build and test
working-directory: apps/bitcoin/bip388/c
run: make test
- name: Build and test under sanitizers
working-directory: apps/bitcoin/bip388/c
run: |
make clean
make test CFLAGS="-fsanitize=address,undefined -O1 -g -std=c11 -Wall -Wextra -Wpedantic -Wno-unused-parameter"

# Ensures the committed generated C sources match the codegen's current output.
# If this fails, regenerate locally with `python3 tools/gen.py` in
# apps/bitcoin/bip388/c/ and commit the result.
check_bip388_c_codegen:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +345 to +366
name: Check bip388 C codegen is up-to-date
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Regenerate
working-directory: apps/bitcoin/bip388/c
run: python3 tools/gen.py
- name: Verify generated files are unchanged
run: |
if [ -n "$(git status --porcelain apps/bitcoin/bip388/c/src/gen/)" ]; then
echo "::error::Generated files in apps/bitcoin/bip388/c/src/gen/ are out of date."
echo "Run 'python3 tools/gen.py' in apps/bitcoin/bip388/c/ and commit the result."
git status --porcelain apps/bitcoin/bip388/c/src/gen/
git diff -- apps/bitcoin/bip388/c/src/gen/
exit 1
fi

vnd_bitcoin_integration_tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
needs: [build_vanadium_app, build_vnd_bitcoin_autoapprove]
uses: ./.github/workflows/reusable_vapp_integration_tests.yaml
with:
Expand Down
1 change: 1 addition & 0 deletions apps/bitcoin/bip388/c/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
67 changes: 67 additions & 0 deletions apps/bitcoin/bip388/c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Build the bip388 C library + test runner.
#
# make # regenerate spec tables, build libbip388.a, link tests
# make test # build and run the test suite
# make clean # remove build artifacts
# make gen # regenerate the codegen output

CC ?= cc
CFLAGS ?= -O2 -g -std=c11 -Wall -Wextra -Wpedantic -Wno-unused-parameter
CPPFLAGS += -Iinclude -Isrc -Isrc/gen

SRC_DIR := src
GEN_DIR := src/gen
TEST_DIR := tests
BUILD_DIR := build

LIB_SOURCES := \
$(SRC_DIR)/util.c \
$(SRC_DIR)/sha256.c \
$(SRC_DIR)/base58.c \
$(SRC_DIR)/xpub.c \
$(SRC_DIR)/time_fmt.c \
$(SRC_DIR)/descriptor.c \
$(SRC_DIR)/keyinfo.c \
$(SRC_DIR)/wallet_policy.c \
$(SRC_DIR)/cleartext.c \
$(GEN_DIR)/cleartext_gen.c

TEST_SOURCES := \
$(TEST_DIR)/test_main.c \
$(TEST_DIR)/test_time.c \
$(TEST_DIR)/test_descriptor.c \
$(TEST_DIR)/test_wallet_policy.c \
$(TEST_DIR)/test_cleartext.c \
$(GEN_DIR)/test_vectors_gen.c

LIB_OBJECTS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(LIB_SOURCES))
TEST_OBJECTS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(TEST_SOURCES))

GEN_SOURCES := \
$(GEN_DIR)/cleartext_gen.c \
$(GEN_DIR)/test_vectors_gen.c \
$(GEN_DIR)/test_vectors_gen.h

.PHONY: all test gen clean

all: $(BUILD_DIR)/libbip388.a $(BUILD_DIR)/test_runner

gen $(GEN_SOURCES):
python3 tools/gen.py

$(BUILD_DIR)/%.o: %.c $(GEN_SOURCES)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

$(BUILD_DIR)/libbip388.a: $(LIB_OBJECTS)
@mkdir -p $(dir $@)
$(AR) rcs $@ $^

$(BUILD_DIR)/test_runner: $(TEST_OBJECTS) $(BUILD_DIR)/libbip388.a
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(TEST_OBJECTS) -L$(BUILD_DIR) -lbip388

test: $(BUILD_DIR)/test_runner
$(BUILD_DIR)/test_runner

clean:
rm -rf $(BUILD_DIR)
Loading
Loading