Skip to content

Commit db030c7

Browse files
committed
Fix linked chunk update when next chunk is not there
1 parent 8e6cc59 commit db030c7

File tree

1 file changed

+33
-0
lines changed
  • crates/matrix-sdk-indexeddb/src/event_cache_store

1 file changed

+33
-0
lines changed

crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,4 +1460,37 @@ mod tests {
14601460
});
14611461
}
14621462
}
1463+
1464+
#[async_test]
1465+
async fn test_linked_chunk_new_gap_chunk() {
1466+
let store = get_event_cache_store().await.expect("creating cache store failed");
1467+
1468+
let room_id = &DEFAULT_TEST_ROOM_ID;
1469+
1470+
store
1471+
.handle_linked_chunk_updates(
1472+
room_id,
1473+
vec![Update::NewGapChunk {
1474+
previous: None,
1475+
new: ChunkIdentifier::new(42),
1476+
next: None,
1477+
gap: Gap { prev_token: "raclette".to_owned() },
1478+
}],
1479+
)
1480+
.await
1481+
.unwrap();
1482+
1483+
let mut chunks = store.reload_linked_chunk(room_id).await.unwrap();
1484+
1485+
assert_eq!(chunks.len(), 1);
1486+
1487+
// Chunks are ordered from smaller to bigger IDs.
1488+
let c = chunks.remove(0);
1489+
assert_eq!(c.identifier, ChunkIdentifier::new(42));
1490+
assert_eq!(c.previous, None);
1491+
assert_eq!(c.next, None);
1492+
assert_matches!(c.content, ChunkContent::Gap(gap) => {
1493+
assert_eq!(gap.prev_token, "raclette");
1494+
});
1495+
}
14631496
}

0 commit comments

Comments
 (0)