From 1489b163727e8bd08945409a525f779e5c4e45f2 Mon Sep 17 00:00:00 2001 From: "torlando-agent[bot]" <281092095+torlando-agent[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:40:02 +0000 Subject: [PATCH] test: close location state boundary coverage --- .../test_custom_location_meta_codec.cpp | 12 ++++++++++ tests/native/test_location_share_state.cpp | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/native/test_custom_location_meta_codec.cpp b/tests/native/test_custom_location_meta_codec.cpp index b754b416..0f32f66b 100644 --- a/tests/native/test_custom_location_meta_codec.cpp +++ b/tests/native/test_custom_location_meta_codec.cpp @@ -134,6 +134,10 @@ void rejectsMalformedAndPreservesOutput() { 0x81, 0xa2, 't', 's', 0xcf, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + constexpr uint8_t expiry_above_columba_long[] = { + 0x81, 0xa7, 'e', 'x', 'p', 'i', 'r', 'e', 's', + 0xcf, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; constexpr uint8_t radius_above_columba_int[] = { 0x81, 0xac, 'a', 'p', 'p', 'r', 'o', 'x', 'R', 'a', 'd', 'i', 'u', 's', @@ -149,6 +153,7 @@ void rejectsMalformedAndPreservesOutput() { {too_many_entries, sizeof(too_many_entries)}, {huge_string, sizeof(huge_string)}, {timestamp_above_columba_long, sizeof(timestamp_above_columba_long)}, + {expiry_above_columba_long, sizeof(expiry_above_columba_long)}, {radius_above_columba_int, sizeof(radius_above_columba_int)}, }; const auto sentinel = expectedMeta(); @@ -187,6 +192,13 @@ void rejectsOutboundValuesOutsideColumbaSignedDomains() { meta, encoded, sizeof(encoded), written) == Telemetry::CustomMetaResult::INVALID_ARGUMENT); + meta = Telemetry::CustomLocationMeta{}; + meta.has_expires = true; + meta.expires_millis = -1; + CHECK(Telemetry::encodeCustomLocationMeta( + meta, encoded, sizeof(encoded), written) == + Telemetry::CustomMetaResult::INVALID_ARGUMENT); + meta = Telemetry::CustomLocationMeta{}; meta.has_approx_radius = true; meta.approx_radius_meters = -1; diff --git a/tests/native/test_location_share_state.cpp b/tests/native/test_location_share_state.cpp index 541454ee..a0900b1a 100644 --- a/tests/native/test_location_share_state.cpp +++ b/tests/native/test_location_share_state.cpp @@ -160,6 +160,12 @@ void enforcesExpiryAndStaleDisplayBoundaries() { CHECK(store.prune(5000, 10000) == 1); CHECK(store.size() == 0); + CHECK(store.apply(id, location(10), meta, 1000) == + Telemetry::PeerLocationResult::INSERTED); + CHECK(store.snapshot(5001, 10000, snapshot, 2) == 0); + CHECK(store.prune(5001, 10000) == 1); + CHECK(store.size() == 0); + Telemetry::CustomLocationMeta no_meta{}; CHECK(store.apply(id, location(1), no_meta, 1000) == Telemetry::PeerLocationResult::INSERTED); @@ -234,6 +240,22 @@ void rejectsDirectMetadataOutsideColumbaDomains() { CHECK(store.apply(peer(33), location(1), meta, 1) == Telemetry::PeerLocationResult::INVALID_ARGUMENT); CHECK(store.size() == 0); + + Telemetry::CustomLocationMeta valid{}; + const auto id = peer(34); + CHECK(store.apply(id, location(2, 123), valid, 2000) == + Telemetry::PeerLocationResult::INSERTED); + Telemetry::PeerLocationRecord before{}; + CHECK(hasPeer(store, id, &before)); + meta = metaTimestamp(1); + meta.timestamp_millis = -1; + CHECK(store.apply(id, location(3, 999), meta, 3000) == + Telemetry::PeerLocationResult::INVALID_ARGUMENT); + Telemetry::PeerLocationRecord after{}; + CHECK(hasPeer(store, id, &after)); + CHECK(after.location.latitude_e6 == before.location.latitude_e6); + CHECK(after.source_timestamp_millis == before.source_timestamp_millis); + CHECK(after.received_at_millis == before.received_at_millis); } void expiredNewerUpdateClearsExistingState() {