Files
pyxis/tests
torlando-tech 6dbbe1bee7 fix(audio): correct degenerate HPF formula in voice filter chain
VoiceFilterChain::applyHighPass collapsed to a constant-gain
multiplier instead of a real high-pass response. The inner loop
read `samples[prevIdx]` as "previous input" — but that slot held
y[n-1] (output) since the previous iteration had overwritten it.
Substituting that into the formula

  y[n] = α(y[n-1] + x[n] - x[n-1])

with x[n-1] := y[n-1] gave

  y[n] = α(y[n-1] + x[n] - y[n-1]) = α · x[n]

i.e. just a fixed gain ≈ 0.81 at 300Hz cutoff / 8kHz. DC offsets
sailed through; the chain only kept signal levels reasonable
because the AGC stage downstream pulled the residual toward target.
The same bug exists in upstream LXST-kt's
native_audio_filters.cpp (filed as LXST-kt#13).

Fix: walk per-channel with explicit `xPrev` / `yPrev` variables so
input history isn't clobbered by the output write. Per-chunk save
of `lastInputs[ch]` now stores the actual last input, not the last
output, so the first sample of each new chunk uses the correct
x[n-1].

Test `dc_offset_attenuated_by_hpf` updated to assert tail RMS
< 0.01 (was < 0.5 — accommodating the broken behavior). Pass.

End-to-end acoustic test (Mac speaker → T-Deck mic): pyxis_rms
went up from 4378 → 5835, bot_rms from 1194 → 1517 — DC offset
removal lets clean signal through better.

Pyxis-side fix only. LXST-kt should pick up the same fix
upstream — see project_lxst_hpf_filter_bug.md in the vault.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 13:27:34 -04:00
..
2026-05-04 14:50:16 -04:00

Pyxis Tests

Three test surfaces, each runnable independently.

1. Pyxis-unique pytest suite

Native C++ tests of pyxis-unique code (BLE fragmenter, HDLC, etc.) and Python tests of build scripts.

/usr/bin/python3 -m pytest tests/build_scripts tests/native -v

System Python 3.9 has pytest pre-installed; Homebrew Python does not.

  • build_scripts/test_patch_nimble.py — verifies patch_nimble.py idempotency, drift detection, missing-file handling
  • native/test_hdlc.{cpp,py} — HDLC escape/unescape/frame round-trip + golden vector against Python RNS
  • native/test_ble_fragmenter.{cpp,py} — BLEFragmenter ↔ BLEReassembler: in-order, out-of-order, duplicate, dropped+timeout, per-peer isolation, MTU change
  • native/test_ble_peer_manager.{cpp,py} — connection-map state machine: discover, identity promotion, blacklist, handle map cleanup, MAC rotation, pool exhaustion
  • native/test_ble_operation_queue.{cpp,py} — GATT op queue: FIFO, busy-state, timeout, clearForConnection, builder
  • native/test_ring_buffers.{cpp,py} — PCM + encoded SPSC ring buffers, including 100k-frame multithreaded producer/consumer stress
  • native/test_audio_filters.{cpp,py} — VoiceFilterChain frequency response, peak limiting, multichannel

Adding a new native C++ test

Pattern: pure C++ unit + thin pytest wrapper.

  1. Write tests/native/test_<thing>.cpp — include from ../../{src,lib/...} for the unit under test, use the existing EXPECT_EQ/EXPECT_TRUE/RUN(name) framework, return non-zero on any failure.
  2. If the unit pulls in microReticulum types, the shims in tests/native/ cover what's been needed so far:
    • Bytes.hbytes_shim.h (minimal RNS::Bytes — append/data/size/writable/resize/mid)
    • Log.h (no-op TRACE/WARNING/INFO/ERROR macros)
    • Utilities/OS.h (OS::time() with set_fake_time()/clear_fake_time())
  3. Write tests/native/test_<thing>.py — copy the test_hdlc.py template, swap source/include paths, run.
  4. Confirm: /usr/bin/python3 -m pytest tests/native/test_<thing>.py -v

2. LXST audio interop tests

Python tests verifying wire format and codec compatibility between pyxis (C++), Python LXST, and LXST-kt (Kotlin).

/usr/bin/python3 -m pytest tests/interop -v

Requires pycodec2 and access to $HOME/repos/public/LXST.

3. microReticulum native unit tests (PlatformIO)

The fork's microReticulum tests live under deps/microReticulum/test/ and run via PlatformIO Unity.

cd deps/microReticulum && pio test -e native17

Use native17, not native — the C++11 env is broken (static-constexpr ODR-use). Baseline as of 2026-05-02: 94/114 PASS, 7 FAIL, 5 SKIPPED, 7 suites ERRORED. The clean suites are test_os, test_bytes, test_msgpack, test_crypto, test_filesystem, test_objects, test_interop, test_general, test_reference, test_example, test_collections.