Skip to content

Add WiFi-Direct survival test for BLE MAC rotation - #146

Open
BigNathan1 wants to merge 2 commits into
StellarConduit:mainfrom
BigNathan1:test/issue-117-wifi-survival
Open

Add WiFi-Direct survival test for BLE MAC rotation#146
BigNathan1 wants to merge 2 commits into
StellarConduit:mainfrom
BigNathan1:test/issue-117-wifi-survival

Conversation

@BigNathan1

@BigNathan1 BigNathan1 commented Jun 29, 2026

Copy link
Copy Markdown

closes #117

Summary

Issue #117 (BLE MAC Address Randomization) defines a set of required tests. The core feature landed in PR #144, but that PR linked closes #38 (the parent privacy issue) rather than #117, and it did not include one of the required tests. This PR adds the missing test so the final acceptance criterion is actually verified, and links the issue.

It also repairs two unrelated breakages on the base branch that currently prevent CI from compiling the crate at all (see "Build fix" below).

Gap addressed (#117)

Issue #117 requires the following test under "Required Tests":

test_notify_mac_rotated_drops_ble_keeps_wifi -- Inject one mock BLE connection and one mock WiFi connection. Call notify_mac_rotated. Assert BLE removed, WiFi retained.

and the matching acceptance criterion:

WiFi-Direct connections survive a MAC rotation.

The merged implementation only added test_notify_mac_rotated_drops_ble_connections, which inserts two BLE connections and asserts both are dropped. No test exercised a WiFi-Direct connection, so the "WiFi-Direct connections survive a MAC rotation" guarantee was never verified. A regression that accidentally widened notify_mac_rotated() to drop non-BLE connections would not have been caught.

Change

Adds test_notify_mac_rotated_drops_ble_keeps_wifi to the transport::unified test module:

  • Injects one real BleCentral connection (TransportType::Ble) and one self-contained mock connection reporting TransportType::WifiDirect.
  • Calls notify_mac_rotated().
  • Asserts the BLE connection is removed, the WiFi-Direct connection is retained, and peer_count is decremented only for the dropped BLE link.

The mock WiFi connection is defined locally inside the test, so no shared test helpers are modified.

Build fix

The base branch does not currently compile, which blocks every CI job (fmt, clippy, tests) before it can evaluate the test above. Two unrelated breakages were introduced by an earlier merge:

  • Cargo.toml declared the reqwest dependency twice (0.12 and 0.11), so cargo metadata aborted with "duplicate key" and fmt/clippy/test failed immediately. Removed the stale 0.11 entry, keeping the 0.12 rustls-tls declaration.
  • src/relay/rpc_client.rs contained an orphaned impl RpcClient { ... } block referencing types that do not exist in the file (SorobanRpcRequest, SendTxParams, RpcClient), leaving an unclosed delimiter and a parse error. The real implementation in this file is impl StellarRpcClient for HorizonRpcClient. Removed the orphaned block; no compiled code references the deleted symbols.

Testing

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --lib

All pass. The new test passes specifically:

cargo test --lib transport::unified::tests::test_notify_mac_rotated_drops_ble_keeps_wifi

Issue StellarConduit#117 requires a test asserting that notify_mac_rotated() drops BLE
connections while preserving WiFi-Direct connections, since WiFi-Direct
links do not reference the BLE MAC address. The merged implementation only
covered the BLE-drop path (test_notify_mac_rotated_drops_ble_connections)
and never asserted that WiFi-Direct connections are retained.

Add test_notify_mac_rotated_drops_ble_keeps_wifi, which injects one BLE
connection and one WiFi-Direct connection, invokes notify_mac_rotated(),
and asserts the BLE connection is removed, the WiFi-Direct connection
remains, and peer_count is decremented only for the dropped BLE link.
The base branch does not currently compile, which blocks every CI job
(fmt, clippy, tests) before it can evaluate this PR. Two unrelated
breakages were introduced by an earlier merge:

- Cargo.toml declared the `reqwest` dependency twice (0.12 and 0.11),
  causing `cargo metadata` to abort with "duplicate key" and failing
  fmt/clippy/test invocations immediately.
- src/relay/rpc_client.rs contained an orphaned `impl RpcClient { ... }`
  block referencing types that do not exist in the file
  (SorobanRpcRequest, SendTxParams, RpcClient), leaving an unclosed
  delimiter and a parse error. The real implementation in this file is
  `impl StellarRpcClient for HorizonRpcClient`.

Remove the duplicate `reqwest` entry (keeping the 0.12 rustls-tls
declaration) and delete the orphaned `impl RpcClient` block. No compiled
code references the removed symbols; the crate now builds, formats, and
passes clippy --all-targets --all-features -- -D warnings.
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.

Implement BLE MAC Address Randomization

1 participant