Repository navigation
Remove dead code and test-only helpers from the library - #283
Merged
Merged
Conversation
Nothing constructed a SendspinTimeFilter with a non-default Config, yet every filter stored the derived values per instance. They are constants in time_filter.cpp now, and the unused get_covariance() is gone.
The unused SsErr values, MIN_ADVERTISED_AUDIO_BYTES_PER_SECOND, PlatformBuffer::location() and the inbound and outbound rings' is_created() had no callers.
close_silently() ignored its goodbye reason, EventFlags::wait() was never asked to wait for all bits, NoiseSession::as_responder() was never given a PSK, and process_player_stream_object() always required every field. Its presence check goes with the parameter: the caller's is_complete() check rejects the same messages.
Both server implementations stored the SendspinClient passed to start() and never read it.
aead_oneshot_decrypt() and the one-shot hmac_sha512() live in the test helpers now. sha256_oneshot(), pairing_code_verify_commit() and AEAD_ONESHOT_NONCE_SIZE are deleted, along with the tests of the verification the client never performs.
Its only override was a test fake, which sets the suite name member instead.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the unused-code and test-helper cleanup.
No open issues 🎉
What changed in this PR
Removes unused internal code and test-only helpers from sendspin-cpp, reducing library complexity and per-instance time-filter storage. The cleanup preserves intended runtime behavior apart from the documented validation log change.
Changes:
- Remove unused functions, constants, accessors, parameters, and write-only state.
- Move test-only crypto helpers into tests and remove an unnecessary virtual test seam.
- Update affected callers, tests, and playback-sync documentation.
| File | Description |
|---|---|
| tests/wrap_test_helpers.h | House the test-only AEAD decrypt helper. |
| tests/test_pairing_state_machine.cpp | Set the fake’s suite member and recompute commitments directly. |
| tests/test_pairing_code.cpp | Remove tests for the deleted commitment verifier. |
| tests/test_crypto.cpp | Use test HMAC helpers and retain streaming SHA-256 coverage. |
| tests/test_cpace.cpp | Include the test-only HMAC helper. |
| tests/record_test_helpers.h | Generate peer IDs using streaming SHA-256. |
| tests/crypto_test_helpers.h | Add a test-only one-buffer HMAC wrapper. |
| src/time_filter.h | Remove configurable construction, stored tuning values, and an unused accessor. |
| src/time_filter.cpp | Replace per-instance tuning values with constants. |
| src/sync_task.cpp | Update event-wait calls to the simplified signature. |
| src/source_task.cpp | Update the startup event-wait call. |
| src/protocol.cpp | Remove a fixed-value parameter and redundant presence check. |
| src/protocol_task.cpp | Update the protocol task’s event-wait call. |
| src/platform/types.h | Remove unused error enum values. |
| src/platform/memory.h | Remove the unused location accessor. |
| src/platform/event_flags.h | Remove wait-all support and update examples. |
| src/platform/crypto.h | Remove unused and test-only crypto helpers. |
| src/outbound_ring.h | Remove the unused creation-status accessor. |
| src/noise_session.h | Simplify responder construction and its documentation. |
| src/noise_session.cpp | Remove the unused construction-time PSK path. |
| src/noise_handshake.cpp | Update responder construction and explanatory comments. |
| src/inbound_ring.h | Remove unused members and update event waits and comments. |
| src/inbound_ring.cpp | Update event-wait calls. |
| src/host/ws_server.h | Remove the unused client parameter and stored pointer. |
| src/host/ws_server.cpp | Simplify server startup accordingly. |
| src/esp/ws_server.h | Remove the unused client parameter and stored pointer. |
| src/esp/ws_server.cpp | Simplify HTTP server startup accordingly. |
| src/crypto/pairing_code.h | Remove the unused commitment-verifier declaration. |
| src/crypto/pairing_code.cpp | Remove the unused commitment-verifier implementation. |
| src/connection.h | Remove a virtual test seam and an ignored close parameter. |
| src/connection.cpp | Update silent-close calls. |
| src/connection_manager.cpp | Update WebSocket server startup arguments. |
| src/connection_manager_pairing.cpp | Update the malformed-message silent-close call. |
| src/client_dispatch.cpp | Update silent-close calls and related comments. |
| docs/playback-sync.md | Describe fixed filter constants instead of removed configuration. |
Review effort: Balanced (adaptive)
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
Removes code nothing runs: unreferenced functions and constants, parameters that only ever took one value, state that is written and never read, and crypto helpers only the tests called. No behavior changes apart from one log line. Net -209 lines.
Change
SendspinTimeFilterwith a non-defaultConfig, yet each filter stored the derived values per instance. They are constants intime_filter.cpp;Config, its constructor and the unusedget_covariance()are gone.SsErrvalues,MIN_ADVERTISED_AUDIO_BYTES_PER_SECOND,PlatformBuffer::location(), andis_created()on the inbound and outbound rings.close_silently()ignored its goodbye reason;EventFlags::wait()was never asked to wait for all bits;NoiseSession::as_responder()was never given a PSK;process_player_stream_object()always required every field.ws_serverimplementations stored theSendspinClient*passed tostart()and never read it.aead_oneshot_decrypt()and the one-shothmac_sha512()move to the test helpers.sha256_oneshot(),pairing_code_verify_commit()andAEAD_ONESHOT_NONCE_SIZEare deleted.get_noise_suite_name()is no longer virtual; the test fake sets the member.Reviewer notes
process_player_stream_object()loses its up-front presence check along with the parameter. The caller'sis_complete()check rejects the same messages, so only the log text differs: "incomplete player object" where it said "missing required fields".get_noise_handshake_hash()stays virtual. The test fake cannot hold an active Noise session without encrypting the sends its tests parse.src/esp/ws_server.{h,cpp}and the FreeRTOS half ofsrc/platform/event_flags.h) were not compiled locally; CI is their first build.Tests
pairing_code_verify_commit()and the verify rows of its length-guard table are deleted with the function;pairing_code_commit()keeps its length-guard table and known-answer test.