Skip to content

test(ffi): c header validation#609

Merged
xdustinface merged 4 commits intov0.42-devfrom
test/c-header-validation
Apr 2, 2026
Merged

test(ffi): c header validation#609
xdustinface merged 4 commits intov0.42-devfrom
test/c-header-validation

Conversation

@ZocoLini
Copy link
Copy Markdown
Collaborator

@ZocoLini ZocoLini commented Mar 31, 2026

  • Created .c files to test the headers are well defined with all the possible includes combination
  • Script to execute this tests
  • Github workflow to execute the tests in CI
  • Made cbindgen prefix the enums generated with the type to avoid present (and future) collisions

Summary by CodeRabbit

  • New Features
    • Generated C headers now include the external key-wallet FFI header for cross-FFI visibility.
  • Refactor
    • Several FFI enum variants renamed for clearer, consistent API naming (manager and funding-type suffixes added).
  • Tests
    • Added small C header test programs that compile against generated FFI headers.
    • Added a script to compile header tests and report pass/fail results.
  • Chores
    • CI updated to run header validation on relevant builds.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Renamed multiple FFI enum variants for clarity, added C header test programs and a header-validation script, updated cbindgen to include an external FFI header, and added a CI step to run header validation.

Changes

Cohort / File(s) Summary
Manager ID Enum Refactoring
dash-spv-ffi/src/callbacks.rs, dash-spv-ffi/src/bin/ffi_cli.rs
Renamed FFIManagerId variants to *Manager (e.g., HeadersHeadersManager) and updated match arms/usages accordingly.
Asset Lock Funding Type Refactoring
key-wallet-ffi/src/transaction.rs
Renamed FFIAssetLockFundingType variants to append FundingType (e.g., IdentityRegistrationIdentityRegistrationFundingType) and updated the From conversion match.
C Header Test Files
ffi-c-tests/header-tests/dash-spv.c, ffi-c-tests/header-tests/key-wallet.c, ffi-c-tests/header-tests/spv_and_key_wallet.c
Added small C programs that include generated FFI headers and invoke basic exported functions to validate header compilation/usability.
C Header Validation Script
ffi-c-tests/validate-headers.sh
Added a script that iterates header-tests/*.c, attempts to compile each with gcc -c, prints pass/fail, and returns an aggregate exit status.
CBindgen & CI Integration
dash-spv-ffi/cbindgen.toml, .github/workflows/build-and-test.yml
Updated cbindgen config to add includes = ["../key-wallet-ffi/key-wallet-ffi.h"] and removed the [parse] section; added a GitHub Actions step “Validate headers” for the ffi matrix group on Ubuntu.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant CI as GitHub Actions
    participant Script as validate-headers.sh
    participant Build as Cargo (build FFI crates)
    participant GCC as gcc (compile tests)
    participant Result as Aggregate Result

    CI->>Script: run validate-headers.sh
    Script->>Build: build FFI crates (produce headers in target/)
    Build-->>Script: headers available
    Script->>GCC: for each header-test.c, run gcc -c with include paths
    GCC-->>Script: success / failure per file
    Script->>Result: print Passed/Failed, set aggregate exit code
    Script-->>CI: exit with aggregate code
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through headers, tiny and bright,
Renamed the names to tidy their flight,
I built and checked each C file with care,
Compiled them cleanly, one hop in the air,
A happy rabbit, nibbling bytes and light 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main objective: adding C header validation tests for FFI components. All changes directly support this goal.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/c-header-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ZocoLini ZocoLini force-pushed the test/c-header-validation branch from cde6e3d to a362c9a Compare March 31, 2026 21:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
dash-spv-ffi/src/bin/ffi_cli.rs (1)

1-491: PR title "test(ffi)" may under-represent the scope of changes.

Per coding guidelines, verify the PR title accurately describes the changes. This file and callbacks.rs contain functional code changes (enum variant renames to fix name collisions), not just test additions. Consider whether the PR title should be fix(ffi) or refactor(ffi) to better reflect the symbol renaming, or split the test infrastructure additions from the collision fixes into separate PRs.

As per coding guidelines: "Check whether the PR title prefix ... accurately describes the changes. Flag e.g. if a PR labeled 'fix' appears to add new functionality..."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash-spv-ffi/src/bin/ffi_cli.rs` around lines 1 - 491, The PR title
"test(ffi)" is misleading because this change includes functional renames (enum
variant renames to avoid symbol collisions) in files such as the FFI callbacks
(e.g., FFISyncState variants and FFIEventCallbacks usage) and callbacks.rs
rather than just tests; update the PR title to accurately reflect the scope (for
example "fix(ffi): rename enum variants to avoid collisions" or "refactor(ffi):
rename FFI enum variants and callbacks") or split the changes into separate PRs
(one for test infra and one for the symbol-renaming fixes) so reviewers can
clearly see the functional rename work on symbols like FFISyncState,
FFIEventCallbacks, and any renamed variants in callbacks.rs.
ffi-c-tests/validate-headers.sh (2)

23-30: Consider adding explicit include path and running the test binary.

Two suggestions for robustness:

  1. Add -I flag for header include path rather than relying on relative paths embedded in test sources.
  2. Consider actually running the compiled binary (./test.bin) to catch runtime link errors—currently only compile-time validation is performed.
♻️ Suggested improvements
 for file in "$HEADER_TESTS_DIR"/*.c; do
-    if gcc "$file" -o test.bin -g -L"$LIB_DIR" -ldash_spv_ffi -lkey_wallet_ffi; then
+    if gcc "$file" -o test.bin -g -I"$TARGET_DIR/debug/include" -L"$LIB_DIR" -ldash_spv_ffi -lkey_wallet_ffi -Wl,-rpath,"$LIB_DIR" && ./test.bin; then
       echo -e "${GREEN}Passed: $file${NC}"
     else
       echo -e "${RED}Failed: $file${NC}"
       EXIT_CODE=1
     fi
 done

Note: If you add -I for explicit include paths, update the .c files to use #include "dash-spv-ffi/dash-spv-ffi.h" instead of the full relative path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ffi-c-tests/validate-headers.sh` around lines 23 - 30, The test loop
currently only compiles each C test using gcc in the for loop that references
HEADER_TESTS_DIR and LIB_DIR; update the gcc invocation to add an explicit
include path (e.g. -I"$HEADER_TESTS_DIR" or another header dir variable) so
headers are resolved via -I instead of baked relative paths, update test sources
to use `#include` "dash-spv-ffi/dash-spv-ffi.h" as noted, and after a successful
compile run the resulting binary (./test.bin) to catch runtime link errors and
set EXIT_CODE on failures; ensure the build step still links -L"$LIB_DIR"
-ldash_spv_ffi -lkey_wallet_ffi and remove/overwrite test.bin between iterations
to avoid stale artifacts.

23-24: Handle case when no .c files exist.

If the header-tests/ directory is empty or contains no .c files, the glob *.c won't expand and the loop may process the literal string "*.c" causing a confusing error.

♻️ Add nullglob or file existence check
+shopt -s nullglob
 for file in "$HEADER_TESTS_DIR"/*.c; do
     if gcc "$file" -o test.bin -g -L"$LIB_DIR" -ldash_spv_ffi -lkey_wallet_ffi; then

Or alternatively:

 for file in "$HEADER_TESTS_DIR"/*.c; do
+    [ -e "$file" ] || continue
     if gcc "$file" -o test.bin -g -L"$LIB_DIR" -ldash_spv_ffi -lkey_wallet_ffi; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ffi-c-tests/validate-headers.sh` around lines 23 - 24, The loop over C files
using the glob "$HEADER_TESTS_DIR"/*.c can iterate the literal "*.c" when no
matches exist; update validate-headers.sh to guard the loop by either enabling
nullglob (e.g., set shell option before the loop) or by performing a pre-check
such as collecting matches into an array from "$HEADER_TESTS_DIR"/*.c and
exiting or skipping if the array is empty; adjust the code around the for file
in "$HEADER_TESTS_DIR"/*.c; do and the subsequent gcc invocation so the loop
only runs when real .c files exist.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dash-spv-ffi/src/bin/ffi_cli.rs`:
- Around line 1-491: The PR title "test(ffi)" is misleading because this change
includes functional renames (enum variant renames to avoid symbol collisions) in
files such as the FFI callbacks (e.g., FFISyncState variants and
FFIEventCallbacks usage) and callbacks.rs rather than just tests; update the PR
title to accurately reflect the scope (for example "fix(ffi): rename enum
variants to avoid collisions" or "refactor(ffi): rename FFI enum variants and
callbacks") or split the changes into separate PRs (one for test infra and one
for the symbol-renaming fixes) so reviewers can clearly see the functional
rename work on symbols like FFISyncState, FFIEventCallbacks, and any renamed
variants in callbacks.rs.

In `@ffi-c-tests/validate-headers.sh`:
- Around line 23-30: The test loop currently only compiles each C test using gcc
in the for loop that references HEADER_TESTS_DIR and LIB_DIR; update the gcc
invocation to add an explicit include path (e.g. -I"$HEADER_TESTS_DIR" or
another header dir variable) so headers are resolved via -I instead of baked
relative paths, update test sources to use `#include`
"dash-spv-ffi/dash-spv-ffi.h" as noted, and after a successful compile run the
resulting binary (./test.bin) to catch runtime link errors and set EXIT_CODE on
failures; ensure the build step still links -L"$LIB_DIR" -ldash_spv_ffi
-lkey_wallet_ffi and remove/overwrite test.bin between iterations to avoid stale
artifacts.
- Around line 23-24: The loop over C files using the glob
"$HEADER_TESTS_DIR"/*.c can iterate the literal "*.c" when no matches exist;
update validate-headers.sh to guard the loop by either enabling nullglob (e.g.,
set shell option before the loop) or by performing a pre-check such as
collecting matches into an array from "$HEADER_TESTS_DIR"/*.c and exiting or
skipping if the array is empty; adjust the code around the for file in
"$HEADER_TESTS_DIR"/*.c; do and the subsequent gcc invocation so the loop only
runs when real .c files exist.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 818333fc-b13e-4327-bc19-b10aa1fbac53

📥 Commits

Reviewing files that changed from the base of the PR and between 2bac44c and a362c9a.

📒 Files selected for processing (9)
  • .github/workflows/ffi-c-tests.yml
  • dash-spv-ffi/cbindgen.toml
  • dash-spv-ffi/src/bin/ffi_cli.rs
  • dash-spv-ffi/src/callbacks.rs
  • ffi-c-tests/header-tests/dash-spv.c
  • ffi-c-tests/header-tests/key-wallet.c
  • ffi-c-tests/header-tests/spv_and_key_wallet.c
  • ffi-c-tests/validate-headers.sh
  • key-wallet-ffi/src/transaction.rs

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.57%. Comparing base (3f65002) to head (451e715).
⚠️ Report is 1 commits behind head on v0.42-dev.

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #609      +/-   ##
=============================================
- Coverage      67.60%   67.57%   -0.04%     
=============================================
  Files            321      321              
  Lines          68258    68258              
=============================================
- Hits           46147    46123      -24     
- Misses         22111    22135      +24     
Flag Coverage Δ
core 75.21% <ø> (ø)
ffi 37.87% <ø> (-0.14%) ⬇️
rpc 19.92% <ø> (ø)
spv 83.82% <ø> (-0.07%) ⬇️
wallet 67.45% <ø> (ø)
see 4 files with indirect coverage changes

@ZocoLini
Copy link
Copy Markdown
Collaborator Author

@QuantumExplorer I modified the enum you added yesterday, want to make sure you like it

@github-actions github-actions bot added the ready-for-review CodeRabbit has approved this PR label Mar 31, 2026
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense generally but the workflow comment i left should be addressed and maybe have a look at https://docs.rs/cbindgen/latest/cbindgen/struct.EnumConfig.html#structfield.prefix_with_name which could be an option to avoid name conflicts? Or the other available options there.. maybe something useful for us.

- name: Install C compiler
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Run header validation script
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step should be included into build-and-test.yml after running the tests guarded by the ffi CI group to avoid rebuilding the crate every time separately.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just did that but it rebuild the crate anyway. CI is building with llvm-cov, creating artifacts in target/llvm-cov-target, but when i build using cargo or cargo rustc the artifacts are being generated in target so it has to rebuild everything from scratch. I did change the script to build as little as possible (only the static lib)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can just set TARGET_DIR and LIB_DIR?

LIB_DIR="$TARGET_DIR/debug"

# Build FFI crates to generate static libraries and header files
cargo build -p dash-spv-ffi --profile dev
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be guarded by an argument if the check gets moved into the existing workflows.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, i dont know what you mean here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean like:

# Build FFI crates unless --skip-build is passed (CI already built them)
if [[ "${1:-}" != "--skip-build" ]]; then
    cargo build -p dash-spv-ffi --profile dev
    cargo build -p key-wallet-ffi --profile dev
fi

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@ZocoLini ZocoLini force-pushed the test/c-header-validation branch from a362c9a to f7f8b3c Compare April 1, 2026 14:54
@github-actions github-actions bot removed merge-conflict The PR conflicts with the target branch. ready-for-review CodeRabbit has approved this PR labels Apr 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
ffi-c-tests/validate-headers.sh (1)

11-13: Respect CARGO_TARGET_DIR to avoid path brittleness.

Lines 11–13 assume ../target. If CARGO_TARGET_DIR is set, header and library paths can break.

♻️ Proposed change
-TARGET_DIR="$SCRIPT_DIR/../target"
+TARGET_DIR="${CARGO_TARGET_DIR:-$SCRIPT_DIR/../target}"
 LIB_DIR="$TARGET_DIR/debug"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ffi-c-tests/validate-headers.sh` around lines 11 - 13, The script hardcodes
TARGET_DIR as "$SCRIPT_DIR/../target" which breaks when CARGO_TARGET_DIR is set;
change TARGET_DIR to respect that environment variable (e.g.
TARGET_DIR="${CARGO_TARGET_DIR:-$SCRIPT_DIR/../target}") and then compute
LIB_DIR from TARGET_DIR (e.g. LIB_DIR="$TARGET_DIR/debug" or use a CARGO_PROFILE
variable if you need release/profile selection) so header/library lookups work
whether or not CARGO_TARGET_DIR is defined.
ffi-c-tests/header-tests/dash-spv.c (1)

1-1: Avoid hardcoding target/debug in header includes.

Line 1 couples this test to a specific target layout/profile. Prefer stable header names and pass include roots from the validator script.

♻️ Proposed change
-#include "../../target/debug/include/dash-spv-ffi/dash-spv-ffi.h"
+#include "dash-spv-ffi/dash-spv-ffi.h"
# companion change in ffi-c-tests/validate-headers.sh compile command:
# add: -I"$LIB_DIR/include"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ffi-c-tests/header-tests/dash-spv.c` at line 1, Replace the hardcoded include
path "#include \"../../target/debug/include/dash-spv-ffi/dash-spv-ffi.h\"" with
a stable header include such as "#include <dash-spv-ffi/dash-spv-ffi.h>" so the
test does not depend on target/debug layout; then update the validator/compile
invocation (validate-headers.sh) to pass the include root (e.g. add
-I"$LIB_DIR/include") so the compiler can locate the header via the new stable
include. Ensure the change touches the include line in dash-spv.c and the
compile command in validate-headers.sh.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build-and-test.yml:
- Around line 93-97: The PR title prefix "test(ffi):" is too narrow because the
change also renames exported FFI enum variants (a fix/refactor), so either
retitle the PR to reflect both testing and code changes (e.g., include
"fix(ffi):" or "refactor(ffi):" alongside testing in the title) or split the
changes into two PRs (one test-only and one that renames enum variants). Update
the pr-title.yml workflow rules if you want to allow combined prefixes, and
ensure the PR title used by the workflow matches the allowed prefixes (reference
the pr-title.yml workflow and the current PR title "test(ffi):..." and the enum
renaming in your FFI changes) so the CI validation and project guidelines are
consistent.

---

Nitpick comments:
In `@ffi-c-tests/header-tests/dash-spv.c`:
- Line 1: Replace the hardcoded include path "#include
\"../../target/debug/include/dash-spv-ffi/dash-spv-ffi.h\"" with a stable header
include such as "#include <dash-spv-ffi/dash-spv-ffi.h>" so the test does not
depend on target/debug layout; then update the validator/compile invocation
(validate-headers.sh) to pass the include root (e.g. add -I"$LIB_DIR/include")
so the compiler can locate the header via the new stable include. Ensure the
change touches the include line in dash-spv.c and the compile command in
validate-headers.sh.

In `@ffi-c-tests/validate-headers.sh`:
- Around line 11-13: The script hardcodes TARGET_DIR as "$SCRIPT_DIR/../target"
which breaks when CARGO_TARGET_DIR is set; change TARGET_DIR to respect that
environment variable (e.g.
TARGET_DIR="${CARGO_TARGET_DIR:-$SCRIPT_DIR/../target}") and then compute
LIB_DIR from TARGET_DIR (e.g. LIB_DIR="$TARGET_DIR/debug" or use a CARGO_PROFILE
variable if you need release/profile selection) so header/library lookups work
whether or not CARGO_TARGET_DIR is defined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 51258edd-5b6b-4b06-b809-563cd824d8e7

📥 Commits

Reviewing files that changed from the base of the PR and between a362c9a and f7f8b3c.

📒 Files selected for processing (9)
  • .github/workflows/build-and-test.yml
  • dash-spv-ffi/cbindgen.toml
  • dash-spv-ffi/src/bin/ffi_cli.rs
  • dash-spv-ffi/src/callbacks.rs
  • ffi-c-tests/header-tests/dash-spv.c
  • ffi-c-tests/header-tests/key-wallet.c
  • ffi-c-tests/header-tests/spv_and_key_wallet.c
  • ffi-c-tests/validate-headers.sh
  • key-wallet-ffi/src/transaction.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • dash-spv-ffi/cbindgen.toml
  • dash-spv-ffi/src/bin/ffi_cli.rs

Comment on lines +93 to +97
- name: Validate headers
if: matrix.group == 'ffi' && inputs.os == 'ubuntu-latest'
run: |
sudo apt update && sudo apt install -y build-essential
bash ffi-c-tests/validate-headers.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

PR title prefix looks too narrow for the actual scope.

test(ffi): ... doesn’t fully reflect that this PR also renames exported FFI enum variants to fix header collisions. Please retitle to include fix/refactor scope (or split if you want a test-only PR).

As per coding guidelines: **: Check whether the PR title prefix allowed in the pr-title.yml workflow accurately describes the changes… and suggest splitting unrelated concerns.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-and-test.yml around lines 93 - 97, The PR title
prefix "test(ffi):" is too narrow because the change also renames exported FFI
enum variants (a fix/refactor), so either retitle the PR to reflect both testing
and code changes (e.g., include "fix(ffi):" or "refactor(ffi):" alongside
testing in the title) or split the changes into two PRs (one test-only and one
that renames enum variants). Update the pr-title.yml workflow rules if you want
to allow combined prefixes, and ensure the PR title used by the workflow matches
the allowed prefixes (reference the pr-title.yml workflow and the current PR
title "test(ffi):..." and the enum renaming in your FFI changes) so the CI
validation and project guidelines are consistent.

@ZocoLini ZocoLini force-pushed the test/c-header-validation branch from f7f8b3c to 8e0f2ec Compare April 1, 2026 15:49
@ZocoLini
Copy link
Copy Markdown
Collaborator Author

ZocoLini commented Apr 1, 2026

@xdustinface about the link you shared, i know about that option and I already mention in the call we had yesterday that it would be the ideal solution to avoid any collision in the future, but at the same time I think we shouldn't be using it in this PR to fix the issues found by gcc, renaming all the enums might force us to change a lot of stuff in iOS and I want to check what changes I would need to do in the other side first. Also, since we are considering UniFFI, i think it would be better if I check on that first

@ZocoLini ZocoLini force-pushed the test/c-header-validation branch 2 times, most recently from 15ba47e to 1aca143 Compare April 1, 2026 23:46
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ffi-c-tests/header-tests/dash-spv.c`:
- Line 1: The test currently hardcodes an environment-dependent include path
("../../target/llvm-cov-target/debug/include/dash-spv-ffi/dash-spv-ffi.h") which
breaks in other environments; change the test source (dash-spv.c) to include the
stable public header name (e.g., "dash-spv-ffi/dash-spv-ffi.h" or the project’s
canonical header path) and remove the hardcoded relative target path, and update
the test build invocation to pass the appropriate -I include directory from the
test script/CI so the compiler can find the header without relying on
"target/.../debug".

In `@ffi-c-tests/header-tests/key-wallet.c`:
- Line 4: The local variable `version` assigned from key_wallet_ffi_version() is
never used and triggers compiler warnings; either mark it explicitly unused
(e.g., cast to void) or perform a simple validation/assertion on it. Update the
test in key-wallet.c where `const char *version = key_wallet_ffi_version();` is
declared so that the variable is consumed—use a void cast or add a basic check
(e.g., ensure version != NULL or length > 0) and handle/report failure to avoid
unused-variable warnings.

In `@ffi-c-tests/header-tests/spv_and_key_wallet.c`:
- Line 8: The local variable `version` assigned from key_wallet_ffi_version() is
unused and causes compiler warnings; update the test to either explicitly mark
it as unused (e.g., cast to void) or perform a minimal validation/assertion on
it (e.g., check it's non-NULL or non-empty) so the value is used; modify the
line with `const char *version = key_wallet_ffi_version();` in
spv_and_key_wallet.c (and add the matching include for assert if you use an
assertion) to eliminate the unused-variable warning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 366b0e04-eb34-4c8f-bb23-4f5756de95b1

📥 Commits

Reviewing files that changed from the base of the PR and between 15ba47e and 1aca143.

📒 Files selected for processing (6)
  • .github/workflows/build-and-test.yml
  • ffi-c-tests/header-tests/dash-spv.c
  • ffi-c-tests/header-tests/key-wallet.c
  • ffi-c-tests/header-tests/spv_and_key_wallet.c
  • ffi-c-tests/validate-headers.sh
  • key-wallet-ffi/src/transaction.rs
✅ Files skipped from review due to trivial changes (1)
  • ffi-c-tests/validate-headers.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/build-and-test.yml
  • key-wallet-ffi/src/transaction.rs

@ZocoLini ZocoLini force-pushed the test/c-header-validation branch from 1aca143 to 55f247f Compare April 2, 2026 16:58
@ZocoLini
Copy link
Copy Markdown
Collaborator Author

ZocoLini commented Apr 2, 2026

@xdustinface done, i basically made the script receive the include dir as the first param and use relative paths to the include directory in the .c files. I hope you like it this way. I also made cbindgen rename all enums to avoid present and future collisions, having to rename variants inside 3 enums was my limit, lets see how this behaves in iOS

@ZocoLini ZocoLini requested a review from xdustinface April 2, 2026 17:07
@ZocoLini ZocoLini force-pushed the test/c-header-validation branch from 55f247f to 451e715 Compare April 2, 2026 17:08
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I feel like there should be some way to use a cargo env var which the script could read instead of having the hard coded path but it works like this for now.

@xdustinface xdustinface merged commit c304954 into v0.42-dev Apr 2, 2026
37 checks passed
@xdustinface xdustinface deleted the test/c-header-validation branch April 2, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants