Skip to content

Add unit tests for public header helpers - #8291

Open
Amaury Chamayou (achamayou) wants to merge 1 commit into
mainfrom
achamayou-header-helper-tests
Open

Add unit tests for public header helpers#8291
Amaury Chamayou (achamayou) wants to merge 1 commit into
mainfrom
achamayou-header-helper-tests

Conversation

@achamayou

Copy link
Copy Markdown
Member

Summary

  • add a focused unit-test target for the low-coverage public header helpers listed in Add unit tests for low-coverage public header helpers #8290
  • cover formatting, parsing, JSON/schema conversion, crypto helpers, synchronization, and boundary/error paths
  • exercise every listed helper's valid and invalid/default cases

Testing

  • build/tests.sh -R '^public_header_helpers_test$' --output-on-failure
  • coverage-enabled build and focused test run

Closes #8290

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5746223b-9c29-40dc-ac18-8ba4c72afb11
Copilot AI lite review requested due to automatic review settings September 4, 2026 17:52
@achamayou
Amaury Chamayou (achamayou) requested a review from a team as a code owner September 4, 2026 17:52

Copilot AI left a comment

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.

🟡 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_test target 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}$");
}
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.

Add unit tests for low-coverage public header helpers

2 participants