commit c5492a5795298358b2963f121789ca488458ac91
parent ca0dcf9352372ba781d7b4489694f0ae2a04219b
Author: triesap <tyson@radroots.org>
Date: Sun, 14 Jun 2026 18:35:14 -0700
runtime: prove exact count only
Diffstat:
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/crates/tangle_runtime/src/runtime.rs b/crates/tangle_runtime/src/runtime.rs
@@ -3041,6 +3041,28 @@ mod tests {
);
}
+ #[test]
+ fn runtime_count_source_stays_exact() {
+ let sources = [
+ include_str!("runtime.rs"),
+ include_str!("relay/core.rs"),
+ include_str!("../../tangle_protocol/src/lib.rs"),
+ ];
+ let forbidden = [
+ concat!("approximate", "_count"),
+ concat!("approx", "_count"),
+ concat!("estimated", "_count"),
+ concat!("count", "_estimate"),
+ concat!("private", "_count", "_estimate"),
+ ];
+
+ for source in sources {
+ for needle in forbidden {
+ assert!(!source.contains(needle));
+ }
+ }
+ }
+
#[tokio::test]
async fn runtime_rate_limits_count_peer_ips() {
let root = temp_root("runtime-count-ip-rate-limit");
diff --git a/crates/tangle_runtime/tests/phase2_acceptance_targets.rs b/crates/tangle_runtime/tests/phase2_acceptance_targets.rs
@@ -870,6 +870,18 @@ async fn websocket_private_and_hidden_groups_do_not_leak_through_query_count_or_
"restricted: count filters are too broad or expensive",
)
.await;
+ send_client_value(
+ &mut observer,
+ json!(["COUNT", "private-approx-count", {"kinds":[1], "#h":["PrivateSocket"], "approximate":true}]),
+ )
+ .await;
+ assert_eq!(
+ read_relay_value(&mut observer).await,
+ json!([
+ "NOTICE",
+ "invalid: filter field `approximate` is unsupported"
+ ])
+ );
assert_empty_req(
&mut observer,
"private-public-query",
@@ -989,6 +1001,18 @@ async fn websocket_private_and_hidden_groups_do_not_leak_through_query_count_or_
"restricted: count filters are too broad or expensive",
)
.await;
+ send_client_value(
+ &mut observer,
+ json!(["COUNT", "hidden-approx-count", {"kinds":[1], "#h":["HiddenSocket"], "approximate":true}]),
+ )
+ .await;
+ assert_eq!(
+ read_relay_value(&mut observer).await,
+ json!([
+ "NOTICE",
+ "invalid: filter field `approximate` is unsupported"
+ ])
+ );
assert_empty_req(
&mut observer,
"hidden-public-query",
@@ -1011,6 +1035,8 @@ async fn websocket_private_and_hidden_groups_do_not_leak_through_query_count_or_
"hidden harvest",
"private-public-broad-count",
"hidden-public-broad-count",
+ "private-approx-count",
+ "hidden-approx-count",
] {
assert!(!metrics.contains(private_value));
}