test(geofence): unit tests for the waypoint geofence alert engine#2083
Conversation
Covers the deterministic core of MeshPackets+Geofence (previously untested): - GeofenceCrossingStore: first observation establishes a baseline (returns nil, never alerts — so an app relaunch can't produce spurious alerts); enter/exit/ enter transition reporting; per-key independence; and — using the production key format — that changing the geofence geometry (radius or bounding box) re-establishes a fresh baseline instead of firing a spurious enter/exit from stale state. Plus a concurrency hammer test for the serial-queue thread safety. - WaypointEntity.contains(location:): circle inside/outside, bounding-box containment (interior/exterior/near-edge), circle+box union semantics, the no-geofence nil case, and boundingBoxCoordinates. - WaypointEntity.applyGeofence(from:): proto→entity mapping including the branch that clears a stale bounding box when the incoming proto has none. The full evaluateGeofences path (actor + LocalNotificationManager) is glue over these units and isn't exercised here to keep the suite deterministic. 18 tests, all passing.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds geofence unit tests for crossing transitions, waypoint geometry, and proto application, then registers ChangesGeofence validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
…ngine # Conflicts: # Meshtastic.xcodeproj/project.pbxproj
What changed?
Adds a unit-test suite (
MeshtasticTests/GeofenceTests.swift, 18 tests in 3 suites) for the waypoint-geofence alert engine (MeshPackets+Geofence), which previously had no test coverage. It exercises the deterministic core:GeofenceCrossingStore— the in-memory crossing-state store that drives enter/exit alerts:(waypoint, node)pair establishes a baseline (returnsnil, never alerts) — so an app relaunch can't produce spurious alerts.DispatchQueue.concurrentPerform) for the serial-queue thread safety.WaypointEntity.contains(location:)— circle inside/outside, bounding-box containment (interior / exterior / near-edge), circle+box union semantics, the no-geofencenilcase, andboundingBoxCoordinates.WaypointEntity.applyGeofence(from:)— proto→entity mapping, including the branch that clears a stale bounding box when the incoming proto has none.Why did it change?
The geofence feature (#2005 / #2001) shipped without unit tests. The baseline/relaunch spurious-alert avoidance and geometry-key rotation are exactly the kind of subtle, easy-to-regress logic that benefits from deterministic coverage. This adds that safety net without touching any production code.
How is this tested?
xcodebuild test— the 3 new suites (GeofenceCrossingStoreTests,WaypointGeofenceGeometryTests,WaypointApplyGeofenceTests), 18 tests, all passing. No production code changed. The fullevaluateGeofencespath (MeshPackets actor +LocalNotificationManager) is glue over these units and is intentionally left out to keep the suite deterministic.Screenshots/Videos (when applicable)
N/A — test-only change.
Checklist
docs/user/ordocs/developer/, and updated accordingly — test-only change, no user- or developer-facing docs affected.skip-docs-checkapplies.Summary by CodeRabbit