From c2b2952749e4cfafcefc304dee7fa72262358b89 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 03:04:04 +0200 Subject: [PATCH] eureka-state tests: reach the limit through the source runtime id, seed the stewardship The source runtime id adds its field name when present, so exact sizes are searched over both paddings. The attribution test admits a campaign, which needs its repo stewarded first. Co-Authored-By: Claude Sonnet 5.5 --- crates/eureka-state/tests/client.rs | 19 +++++++++++-------- crates/eureka-state/tests/mcp.rs | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/crates/eureka-state/tests/client.rs b/crates/eureka-state/tests/client.rs index ff7d50c..6a054ea 100644 --- a/crates/eureka-state/tests/client.rs +++ b/crates/eureka-state/tests/client.rs @@ -423,15 +423,18 @@ fn smallest_request_over() -> HuginnMindRequest { padded_admit(pad_for(MAX_REQUEST_BYTES + 1)) } -/// A message that encodes to exactly `target` bytes: the largest request that -/// fits under it, topped up with a source runtime id, which rides outside the -/// payload and moves the size a byte at a time. +/// A message that encodes to exactly `target` bytes: a request a little under +/// it, topped up with a source runtime id, which rides outside the payload and +/// moves the size a byte at a time once the field is there at all. fn message_of_size(target: usize) -> CultNetMessage { - let request = padded_admit(pad_for(target + 1) - 1); - for pad in 0..16 { - let message = message_for(&request, (pad > 0).then(|| "r".repeat(pad))); - if encoded_bytes(&message) == target { - return message; + let fitting = pad_for(target + 1) - 1; + for padding in (fitting.saturating_sub(80)..=fitting).rev() { + let request = padded_admit(padding); + for source in 1..80 { + let message = message_for(&request, Some("r".repeat(source))); + if encoded_bytes(&message) == target { + return message; + } } } panic!("no message encodes to {target} bytes"); diff --git a/crates/eureka-state/tests/mcp.rs b/crates/eureka-state/tests/mcp.rs index f6def4c..3a51eb0 100644 --- a/crates/eureka-state/tests/mcp.rs +++ b/crates/eureka-state/tests/mcp.rs @@ -413,7 +413,7 @@ fn an_oversize_admit_is_a_typed_too_large_error() { /// is a typed refusal, and nothing is committed. #[test] fn admit_refuses_an_unusable_attribution() { - let (root, daemon) = mind(vec![]); + let (root, daemon) = mind(vec![vec![stewardship()]]); let server = serve(root, daemon); let mut mcp = Mcp::at(INSTANCE, server.addr); for (field, value) in [ @@ -437,7 +437,7 @@ fn admit_refuses_an_unusable_attribution() { ); } let (_, whoami) = mcp.call("whoami", json!({})); - assert_eq!(whoami["status"]["receipts"], json!(1), "only the seed is committed: {whoami}"); + assert_eq!(whoami["status"]["receipts"], json!(2), "only the seed is committed: {whoami}"); let (error, admitted) = mcp.call("admit", faculty_args(vec![campaign_json()])); assert!(!error); assert!(admitted.get("Committed").is_some(), "{admitted}");