Skip to content

Add server protocol tests ported from thingset-node-c - #78

Merged
garethpotter merged 1 commit into
mainfrom
server-protocol-tests
Nov 6, 2026
Merged

garethpotter merged 1 commit into
mainfrom
server-protocol-tests

Conversation

@garethpotter

Copy link
Copy Markdown
Collaborator

Adds tests/TestServerProtocol.cpp: request/response tests for the server, ported from thingset-node-c's tests/protocol and tests/serde. Because the cases and expected responses come from thingset-node-c, they also check that the two implementations behave the same.

What's covered

  • Request/response: get, fetch, update and exec, in binary and text mode, sent straight to handleBinaryRequest / handleTextRequest.
  • Cross-mode round trips: a value updated in text mode is read back in binary, and the reverse, for integers of every size at their boundaries, floats, bools and strings. Includes non-minimal CBOR encodings such as 19 00 FF.
  • Out-of-range values: updates that don't fit the target type are rejected (added here; not from thingset-node-c).

A fixture rebuilds part of thingset-node-c's test data model (Types, Arrays, Exec, Access, Nested), with the same names and with IDs offset by 0xB000 so they don't collide with other tests. Error responses are checked by status code only, since thingset-node-c also sends a diagnostic message.

Disabled tests

38 tests pass. 29 are DISABLED_ because thingset++ currently behaves differently. Each expects thingset-node-c's behaviour and has a comment saying what thingset++ does instead. All 29 currently fail with --gtest_also_run_disabled_tests.

Bugs:

  • binary 8/16-bit decoders reject the type's maximum (< instead of <=), and signed ones have no lower bound (-129 into int8_t becomes 127)
  • text integer decoding has no range check (256 into uint8_t becomes 0)
  • text decoder doesn't move past true/false, so a list ending in a bool fails (e.g. calling a function with a bool parameter)
  • text strings aren't unescaped on input or escaped on output
  • inf/nan are written as bare inf/nan (not valid JSON)
  • malformed JSON in a text update is accepted
  • binary get by name answers with IDs as keys

Differences from thingset-node-c that may be design decisions:

  • fetching selected items (?Types ["wF32","wBool"]) isn't supported; text mode treats it as a get
  • updates aren't all-or-nothing: items before a failing one are written
  • getting a group includes subgroups in full (thingset-node-c uses null) and leaves functions out
  • text floats always have six decimal places, and bools are 1/0
  • text exec of a function with no parameters needs []
  • exec with a wrong parameter type gives A0 (thingset-node-c AF), and exec of a non-function gives A0 (thingset-node-c A3)

Fixes for the first three bugs, and for bools in text mode, will follow in a separate PR that re-enables their tests.

🤖 Generated with Claude Code

Request/response tests for get, fetch, update and exec in binary and
text mode, plus cross-mode round trips (update in one mode, get in the
other) for each value type. The cases, data model and expected responses
follow thingset-node-c's tests/protocol and tests/serde, so they also
check the two implementations behave the same.

Where thingset++ currently differs, the test expects thingset-node-c's
behaviour and is disabled, with a note saying what thingset++ does
instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@garethpotter
garethpotter merged commit 23684c6 into main Nov 6, 2026
6 checks passed
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