Skip to content

Fix the two failing admin request-pinning tests on develop - #11124

Merged
thebentern merged 1 commit into
developfrom
fix/admin-pin-tests-simradio
Jul 21, 2026
Merged

Fix the two failing admin request-pinning tests on develop#11124
thebentern merged 1 commit into
developfrom
fix/admin-pin-tests-simradio

Conversation

@thebentern

@thebentern thebentern commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

develop is currently red on test-native. Two tests in test/test_admin_session_repro/ have failed since #11092 added them, and every branch that merges develop inherits the failure (e.g. #10967).

test_main.cpp:472:test_pinned_request_keeps_its_key_after_an_unpinned_request:FAIL: an unpinned request must not relax an earlier request's key pin
test_main.cpp:491:test_request_to_keyed_node_pins_the_stored_key:FAIL: a plaintext response must not answer a PKC-pinned request

Root cause

The native test harness boots Portduino in simulated mode (the run prints Running in simulated mode., PortduinoGlue.cpp:362). wouldEncryptWithPKC() short-circuits on that:

return isFromUs(p) &&
#if ARCH_PORTDUINO
       !portduino_config.force_simradio &&   // always false under the harness
#endif

noteOutgoingAdminRequest() derives the pin from that predicate:

keyValid = haveDestKey && wouldEncryptWithPKC(&p, p.channel, haveDestKey);

so keyValid is never set, nothing is pinned, and responseIsSolicited() admits a plaintext response to what should be a PKC-pinned request — exactly the two assertions.

Instrumenting the predicate confirms every other term was already satisfied, leaving only the simradio guard:

[DBG-PIN] to=0x0c0c0c0c haveDestKey=1 wouldPKC=0 keyValid=0 | isFromUs=1 privKey=32 bcast=0 portnum=6 chName=LongFast

Fix

Clear the flag in setUp so the fixture models a real device.

Skipping PKC under force_simradio is correct for a simulated radio — there is no PKC to pin — so this deliberately does not relax wouldEncryptWithPKC() to make a test pass. The change is test-only.

The only sim-mode path in this suite is AdminModule's exit_simulator intercept, which no test here exercises, so clearing the flag cannot affect a sibling test.

Verification

Full native suite on this branch (Docker, coverage env, ASan/LSan):

  • 38 suites, 723/723 cases, 0 sanitizer findings, 0 ignored
  • both previously-failing tests now PASS

For contrast, develop at d587f0848 reports 724 test cases: 2 failed, 721 succeeded.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated device authentication test coverage for Portduino builds.
    • Tests now run against non-simulated device behavior, ensuring key-pinning scenarios are exercised correctly.

The native test harness boots Portduino in simulated mode, and
wouldEncryptWithPKC() short-circuits to false whenever
portduino_config.force_simradio is set. noteOutgoingAdminRequest() derives its
pin from that predicate:

    keyValid = haveDestKey && wouldEncryptWithPKC(&p, p.channel, haveDestKey);

so under the harness no outgoing admin request is ever key-pinned, and
responseIsSolicited() admits a plaintext response to a PKC-pinned request.
test_pinned_request_keeps_its_key_after_an_unpinned_request and
test_request_to_keyed_node_pins_the_stored_key have therefore failed since
#11092 added them, on develop and on every branch that merges it.

Instrumenting the predicate shows every other term already satisfied
(haveDestKey=1, isFromUs=1, private_key=32, unicast, ADMIN_APP, channel
LongFast) with wouldEncryptWithPKC=0, leaving only the simradio guard.

Clear the flag in setUp so the fixture models a real device. Skipping PKC under
force_simradio is correct for a simulated radio - there is no PKC to pin - so
the predicate is left alone rather than relaxed to make a test pass. The only
sim-mode path in this suite is AdminModule's exit_simulator intercept, which no
test here exercises.

Native suite: 38 suites, 723/723 cases, no sanitizer findings.
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (30)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Meshnology W10 meshnology_w10 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Pocket V3 rak_wismesh_pocket nrf52840
RAK WisMesh Pod rak_wismesh_pod nrf52840
RAK WisMesh Repeater Mini V2 rak_wismesh_repeater_mini nrf52840
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed SenseCAP Mesh-Tracker-X1 seeed_mesh_tracker_X1 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LILYGO T-Impulse Plus t-impulse-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-08-20. Updated for 6fc7c1b.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The admin session repro test now includes Portduino glue on Portduino builds and disables forced simradio behavior during test setup, allowing PKC key-pinning logic to run in a non-simulated device configuration.

Changes

Portduino admin session test

Layer / File(s) Summary
Configure Portduino test execution
test/test_admin_session_repro/test_main.cpp
Includes the Portduino glue header and sets portduino_config.force_simradio to false during setup for Portduino builds.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: caveman99, jp-bennett

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing the failing admin request-pinning tests on develop.
Description check ✅ Passed It covers the bug, root cause, fix, and verification, but omits the repository's attestations checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/admin-pin-tests-simradio

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/test_admin_session_repro/test_main.cpp`:
- Around line 164-170: Shorten the comment above portduino_config.force_simradio
to one or two lines, retaining only the essential rationale that simulated mode
disables PKC and prevents the pinning tests from exercising their assertions.
Leave the assignment unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f24ad154-3c4c-4c03-9e84-f54e3e7dc1ab

📥 Commits

Reviewing files that changed from the base of the PR and between a58daf0 and 6fc7c1b.

📒 Files selected for processing (1)
  • test/test_admin_session_repro/test_main.cpp

Comment on lines +164 to +170
#ifdef ARCH_PORTDUINO
// The native test harness boots Portduino in simulated mode, and wouldEncryptWithPKC()
// hard-disables PKC whenever force_simradio is set. Left true, no outgoing admin request is
// ever key-pinned, so the pinning tests below cannot exercise what they are asserting.
// Model a real (non-sim) device instead.
portduino_config.force_simradio = false;
#endif

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Shorten the explanatory comment.

The four-line comment exceeds the project’s one-or-two-line comment limit. Keep only the essential rationale; the force_simradio assignment is already self-explanatory.

Proposed revision
 `#ifdef` ARCH_PORTDUINO
-    // The native test harness boots Portduino in simulated mode, and wouldEncryptWithPKC()
-    // hard-disables PKC whenever force_simradio is set. Left true, no outgoing admin request is
-    // ever key-pinned, so the pinning tests below cannot exercise what they are asserting.
-    // Model a real (non-sim) device instead.
+    // Disable simulated-radio gating so these tests exercise PKC pinning.
     portduino_config.force_simradio = false;
 `#endif`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#ifdef ARCH_PORTDUINO
// The native test harness boots Portduino in simulated mode, and wouldEncryptWithPKC()
// hard-disables PKC whenever force_simradio is set. Left true, no outgoing admin request is
// ever key-pinned, so the pinning tests below cannot exercise what they are asserting.
// Model a real (non-sim) device instead.
portduino_config.force_simradio = false;
#endif
`#ifdef` ARCH_PORTDUINO
// Disable simulated-radio gating so these tests exercise PKC pinning.
portduino_config.force_simradio = false;
`#endif`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/test_admin_session_repro/test_main.cpp` around lines 164 - 170, Shorten
the comment above portduino_config.force_simradio to one or two lines, retaining
only the essential rationale that simulated mode disables PKC and prevents the
pinning tests from exercising their assertions. Leave the assignment unchanged.

Source: Coding guidelines

@thebentern
thebentern merged commit fdb7668 into develop Jul 21, 2026
104 of 106 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.

1 participant