From 0cfc1243bc109e5758fb6fc9b6d0abdd7f0b3973 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:41:48 -0600 Subject: [PATCH] test(id): read the records page from the probe handle, not republished records (#5128) records_read_pages_fit_the_result_event_that_delivers_them has been red since it landed in #5092: the paging code works (the request executes and a 64287-byte result event is delivered to the program), but the probe republished its captured results as a single "results" record. parse_records caps one record value at MAX_RECORD_VALUE_BYTES (8 KiB), so deliver() refused the publication, marked the program unhealthy, and the test read the untouched channel and panicked at the index. The sibling BoundsProbe test survives only because its captured results are small. The probe now shares captured results with the test through an Arc> handle (the pattern other probes in this file use) and publishes no records. Every page assertion is unchanged: ok, exactly 8 of 16 records at the 64512-byte cap-result bound, first key r00, next_after r07. The filed suspects (#4585, the paging code) are innocent: the disagreement was between the test readout and the records bound, not the paging. --- pkgs/id/src/world/tests.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/pkgs/id/src/world/tests.rs b/pkgs/id/src/world/tests.rs index 05c3ab2674..a2af96f2a8 100644 --- a/pkgs/id/src/world/tests.rs +++ b/pkgs/id/src/world/tests.rs @@ -1107,10 +1107,16 @@ mod tests { // result_too_large error above 64 KiB, so the program never saw // a single record. The page must now stop at the cap-result // bound and deliver records, with next_after naming the rest. + // Captured results are shared with the test through a handle, not + // republished as records: a full page result is ~64 KiB, and + // parse_records caps one record value at MAX_RECORD_VALUE_BYTES + // (8 KiB), so a records readout makes deliver() refuse the + // publication and the test would read an empty channel (#5128). + // The delivery under test is the result event reaching update(). #[derive(Debug, Default)] struct PageProbe { answered: BTreeSet, - results: BTreeMap, + results: Arc>>, } impl WorldProgram for PageProbe { @@ -1122,7 +1128,10 @@ mod tests { && let Some(id) = value["id"].as_str() { self.answered.insert(id.to_owned()); - self.results.insert(id.to_owned(), value); + self.results + .lock() + .unwrap() + .insert(id.to_owned(), value); } } Ok(()) @@ -1143,17 +1152,18 @@ mod tests { )) } - fn records(&mut self) -> Result> { - Ok(Some( - serde_json::json!({"results": self.results}).to_string(), - )) - } } let mut core = world(128); core.ledger .set_granted(BTreeSet::from(["records.read".to_owned()])); - let mut actor = WorldActor::for_test(core, Box::new(PageProbe::default()), None); + let captured: Arc>> = + Arc::new(std::sync::Mutex::new(BTreeMap::new())); + let probe = PageProbe { + results: captured.clone(), + ..Default::default() + }; + let mut actor = WorldActor::for_test(core, Box::new(probe), None); let mut injected = Records::new(); for index in 0..16 { injected.insert( @@ -1165,8 +1175,8 @@ mod tests { actor.after_change().await; - let records = actor.records_sender.borrow().1.clone(); - let page = &records["results"]["records-page"]; + let captured = captured.lock().unwrap(); + let page = &captured["records-page"]; assert_eq!(page["ok"], true, "{page}"); let delivered = page["value"]["records"].as_array().unwrap(); // Each serialized entry is 8025 bytes with its comma; the