mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-08-28 23:00:28 +00:00
test: close location state boundary coverage
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user