Add unit tests for public header helpers - #8291
Open
Amaury Chamayou (achamayou) wants to merge 1 commit into
Open
Add unit tests for public header helpers#8291Amaury Chamayou (achamayou) wants to merge 1 commit into
Amaury Chamayou (achamayou) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5746223b-9c29-40dc-ac18-8ba4c72afb11
Copilot started reviewing on behalf of
Amaury Chamayou (achamayou)
September 4, 2026 17:53
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new unit tests include a potentially incorrect hard-coded schema expectation and a concurrency test pattern that can be made more robust to avoid hangs/missed notifications.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new focused unit-test binary to increase coverage of several small helper APIs defined in public headers under include/ccf/**, aligning with the coverage gaps described in #8290.
Changes:
- Added a new doctest-based unit test source file exercising enum/string helpers, JSON/schema helpers, and small parsing/formatting utilities.
- Registered a new
public_header_helpers_testtarget in the build, linking required dependencies for llhttp-based helpers.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
File summaries
| File | Description |
|---|---|
| src/ds/test/public_header_helpers.cpp | New unit tests covering multiple public header helper utilities (formatting/parsing/JSON/schema/concurrency helpers). |
| CMakeLists.txt | Adds a dedicated unit-test target for the new public-header helper tests and links http_parser. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+281
to
+299
| ccf::ds::ConditionVariable condition_variable; | ||
| std::atomic<bool> entered = false; | ||
| std::atomic<bool> woke = false; | ||
| std::thread waiter([&]() { | ||
| ccf::ds::MutexGuard guard(mutex); | ||
| entered.store(true, std::memory_order_release); | ||
| condition_variable.wait(guard); | ||
| woke.store(true, std::memory_order_release); | ||
| }); | ||
|
|
||
| while (!entered.load(std::memory_order_acquire)) | ||
| { | ||
| std::this_thread::yield(); | ||
| } | ||
|
|
||
| { | ||
| ccf::ds::MutexGuard guard(mutex); | ||
| condition_variable.notify_one(); | ||
| } |
Comment on lines
+311
to
+315
| ccf::fill_json_schema(schema, static_cast<const ccf::ClaimsDigest*>(nullptr)); | ||
| CHECK(schema["type"] == "string"); | ||
| CHECK(schema["format"] == "hex"); | ||
| CHECK(schema["pattern"] == "^[a-f0-9]{32}$"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
build/tests.sh -R '^public_header_helpers_test$' --output-on-failureCloses #8290