Testing EDB

July 10, 2026 ยท View on GitHub

Run everything

make test
cd services/edb-gateway && pip install -e ".[dev]" && pytest

On Windows without make, run the individual commands below.

Native C++ tests

Host-native tests compile EDB.cpp with an in-memory fake storage backend.

make -C test test        # 2.0.0 library + crypto suites
make -C test test-107    # 1.0.7 drop-in library
make -C test test-crypto # explicit crypto target

On Windows with g++ or clang++ installed:

powershell -File test/build.ps1

Requirements: g++ with C++11 support.

Test suites

SuiteFilePurpose
Smoketest_edb.cppCore API validation, stable ids, ring FIFO (fifoFirstRec/fifoNextRec)
Edge / scaletest_edb_edge.cppLarge tables (4k+ records, 1 MiB capacity), sparse tombstones, ring wrap, large payloads
Data integritytest_edb_integrity.cppFull-table record preservation
Code integritytest_api_compat.cppRegression cases + golden fixtures
Cryptotest_crypto.cppAEAD round-trip, wrong key
Crypto headertest_crypto_header.cppEncryption extension parse/write
Crypto integritytest_crypto_integrity.cppShift ops on ciphertext slots
Crypto blindtest_crypto_blind.cppOpaque byte storage
Compile flagstest_compile_flags.cppOptional feature guards

Data integrity coverage

  • Shift operations (delete/insert at first, middle, last) verify all records
  • Failed append/insert/malloc paths leave storage unchanged
  • Reopen after mixed operations preserves data
  • Byte vs buffer handler parity (identical on-disk bytes)
  • v2-only: v1 AVR upgrade preserves records

Code integrity coverage

  • recno == 0 returns EDB_OUT_OF_RANGE without mutating storage
  • Corrupt open() returns EDB_ERROR
  • Golden fixtures in test/fixtures/ (generate with make -C test fixtures)
  • API check: python scripts/check_api.py
  • Crypto vectors: test/fixtures/crypto_vectors.json

Gateway tests (Python)

cd services/edb-gateway
pip install -e ".[dev]"
pytest

Uses MockTransport โ€” no hardware required. Covers protocol, REST, encrypted transport pairing, dev-mode guards, and log redaction.

Optional hardware serial test

With ESP32 running EDB_SerialBridge:

EDB_GATEWAY_INSECURE=1 pytest -m serial   # when serial tests are added

Host tool tests

python -m unittest discover -s tools -p "test_*.py"

Covers migration (test_edb_migrate), vacuum/repack (test_edb_vacuum), grow (test_edb_grow), and large-file edge cases (test_edb_edge): 20k-slot sparse tables, megabyte grow, multi-table scan.

Arduino compile check

If arduino-cli is installed:

arduino-cli lib install "SD"
arduino-cli compile --fqbn arduino:avr:uno examples/EDB_Simple
arduino-cli compile --library . --fqbn esp32:esp32:esp32 examples/EDB_SerialBridge

Continuous integration

GitHub Actions workflow .github/workflows/test.yml runs:

  1. Native C++ tests (2.0.0) including crypto suites
  2. Native C++ tests (1.0.7 drop-in)
  3. Host tool tests (tools/test_*.py)
  4. Public API compatibility check
  5. Arduino example compiles (AVR + ESP32 SerialBridge)
  6. Gateway pytest suite

Testing without hardware

Host-native tests (make -C test test) and gateway pytest exercise library and service logic without an Arduino board. Use a real board or Wokwi for final EEPROM/SD integration checks.