MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / enqueue_and_dequeue

Function enqueue_and_dequeue

nodedb-crdt/src/dead_letter.rs:242–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240
241 #[test]
242 fn enqueue_and_dequeue() {
243 let mut dlq = DeadLetterQueue::new(10);
244 let c = test_constraint();
245
246 let id = dlq
247 .enqueue(
248 42,
249 0,
250 0,
251 b"delta-bytes".to_vec(),
252 &c,
253 "email already exists".into(),
254 CompensationHint::RetryWithDifferentValue {
255 field: "email".into(),
256 conflicting_value: "alice@example.com".into(),
257 suggestion: "alice+1@example.com".into(),
258 },
259 )
260 .unwrap();
261
262 assert_eq!(dlq.len(), 1);
263 assert_eq!(id, 1);
264
265 let dl = dlq.dequeue().unwrap();
266 assert_eq!(dl.peer_id, 42);
267 assert_eq!(dl.violated_constraint, "users_email_unique");
268 assert!(dlq.is_empty());
269 }
270
271 #[test]
272 fn capacity_enforced() {

Callers

nothing calls this directly

Calls 4

test_constraintFunction · 0.85
dequeueMethod · 0.80
enqueueMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected