Skip to content

Cover the source role with loopback wire-order tests - #115

Draft
chrisuthe wants to merge 12 commits into
source-role/03-role-pcmfrom
source-role/04-wire-tests
Draft

Cover the source role with loopback wire-order tests#115
chrisuthe wants to merge 12 commits into
source-role/03-role-pcmfrom
source-role/04-wire-tests

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

Part 4/6 of the source@v1 stack (tracker: #95).

What it adds: loopback wire-order integration tests for the source role — a real client against an in-test WebSocket server, proving client-stream/start → typed+timestamped chunks → client-stream/end ordering and every streaming gate (no start command, stale connection, no time sync, permission reset on reconnect).

How it's used: tests only; no library changes.

@chrisuthe
chrisuthe force-pushed the source-role/04-wire-tests branch from d9abea6 to 548df24 Compare September 1, 2026 02:32
@chrisuthe chrisuthe closed this Sep 3, 2026
@chrisuthe chrisuthe reopened this Sep 4, 2026
@chrisuthe chrisuthe added the enhancement New feature or request label Sep 4, 2026

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

Several tests can pass without fully verifying payload integrity or delayed permission leakage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds loopback integration coverage for source-role streaming and connection gates.

Changes:

  • Tests wire ordering and PCM framing.
  • Covers time-sync gating and reconnect permission reset.
  • Adds an in-test WebSocket server harness.
File summaries
File Description
tests/test_source_role.cpp Adds source-role loopback integration tests.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_source_role.cpp Outdated
Comment thread tests/test_source_role.cpp Outdated
Comment thread tests/test_source_role.cpp
Audit every payload byte of every chunk against the write-side ramp,
pin the end-to-end test's 25 ms chunk arithmetic explicitly instead of
leaning on the config default, split the mid-stream validation probes
into their own focused test with an accepting control, and outlast the
failed-open retry window before the reconnect test's fresh command.

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 tests do not reliably prove pre-command gating or server-time timestamp conversion.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread tests/test_source_role.cpp
Comment thread tests/test_source_role.cpp Outdated
Comment thread tests/test_source_role.cpp Outdated
The fake server now runs its clock a known 500 ms ahead, so the
ordering test asserts each chunk timestamp lands in the server domain
(base + offset) rather than near the raw client stamp -- dropping the
compute_server_time() conversion would now fail the test. Add an
explicit quiet window past the failed-open retry interval before the
start command so an erroneous unsolicited open surfaces, and correct
the framing comment to describe the test's pinned 25 ms config rather
than the 20 ms role default.

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

Duplicate-start coverage is nondeterministic, and new standard-library usages lack direct includes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +638 to +640
fake.send_source_command("start");
pump_for(harness.client, 300);
EXPECT_EQ(fake.count_text_containing("client-stream/start"), 1U);
#include "source_task.h"
#include <ArduinoJson.h>
#include <gtest/gtest.h>
#include <ixwebsocket/IXWebSocket.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants