Skip to content

Commit f561395

Browse files
committed
test(sync): assert plain document scan returns synced rows
Adds a proof step verifying that a text-match-free DocumentScan observes the 3 synced documents, confirming CRDT deltas materialize into the sparse document store (shape-servable), not just the FTS index.
1 parent 9a1ed2c commit f561395

1 file changed

Lines changed: 38 additions & 12 deletions

File tree

nodedb-lite/tests/sync_interop_collection_registration.rs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,20 @@ async fn document_collection_registers_on_origin_via_announce() {
174174
CollectionSchema announce (no Origin pre-create) within the deadline"
175175
);
176176

177-
// PROOF 2 — data served: the synced documents must be queryable on Origin.
178-
// Synced schemaless documents are read via the always-on BM25 index
179-
// (`text_match`), the same read path the FTS interop test exercises; each
180-
// body contains the term "registration".
177+
// PROOF 2 — shape-servable: a plain document scan (`SELECT id`, the same
178+
// `DocumentScan` path a `ShapeSnapshot` uses) must return all 3 synced
179+
// documents. This is the literal #146 symptom: before the Origin-side
180+
// CRDT-delta materialization fix, the synced deltas were acked but never
181+
// written to the sparse document store, so this scan returned 0 rows
182+
// (ShapeSnapshot doc_count=0). It must now return 3.
181183
let mut origin_row_count: usize = 0;
182184
let deadline = tokio::time::sleep(Duration::from_secs(8));
183185
tokio::pin!(deadline);
184186
loop {
185187
tokio::select! {
186188
_ = &mut deadline => break,
187189
_ = tokio::time::sleep(Duration::from_millis(200)) => {
188-
if let Ok(rows) = pg
189-
.try_query(
190-
"SELECT id FROM doc_reg_test \
191-
WHERE text_match(body, 'registration') LIMIT 10",
192-
)
193-
.await
190+
if let Ok(rows) = pg.try_query("SELECT id FROM doc_reg_test").await
194191
&& rows.len() >= 3
195192
{
196193
origin_row_count = rows.len();
@@ -201,8 +198,37 @@ async fn document_collection_registers_on_origin_via_announce() {
201198
}
202199
assert_eq!(
203200
origin_row_count, 3,
204-
"Origin must serve 3 synced documents for doc_reg_test after registration \
205-
via the CollectionSchema announce (no Origin pre-create); got {origin_row_count}"
201+
"Origin must serve 3 synced documents via a plain document scan for \
202+
doc_reg_test after registration via the CollectionSchema announce \
203+
(no Origin pre-create); got {origin_row_count}"
204+
);
205+
206+
// PROOF 3 — shape-servable materialization (the exact #146 symptom): a
207+
// plain document scan (`SELECT id`, no text_match) must also return the 3
208+
// synced rows. This is the path `DocumentScan` / `ShapeSnapshot` read, so a
209+
// non-zero count here means the CRDT deltas materialized into the sparse
210+
// document store — i.e. the collection is shape-servable, not just
211+
// FTS-searchable.
212+
let mut scan_row_count: usize = 0;
213+
let deadline = tokio::time::sleep(Duration::from_secs(8));
214+
tokio::pin!(deadline);
215+
loop {
216+
tokio::select! {
217+
_ = &mut deadline => break,
218+
_ = tokio::time::sleep(Duration::from_millis(200)) => {
219+
if let Ok(rows) = pg.try_query("SELECT id FROM doc_reg_test").await
220+
&& rows.len() >= 3
221+
{
222+
scan_row_count = rows.len();
223+
break;
224+
}
225+
}
226+
}
227+
}
228+
assert_eq!(
229+
scan_row_count, 3,
230+
"Origin plain document scan must return 3 synced rows (shape-servable) \
231+
after CRDT deltas materialize into the document store; got {scan_row_count}"
206232
);
207233

208234
// Cleanup.

0 commit comments

Comments
 (0)