MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / register_interest_sort_value

Function register_interest_sort_value

api/src/tests.rs:364–416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

362
363#[test(tokio::test)]
364async fn register_interest_sort_value() {
365 let node_id = NodeKey::random().id();
366 let network = Network::InMemory;
367 let model = "k2t6wz4ylx0qr6v7dvbczbxqy7pqjb0879qx930c1e27gacg3r8sllonqt4xx9"; // cspell:disable-line
368
369 // Construct start and end event ids
370 let start = EventId::builder()
371 .with_network(&network)
372 .with_sep("model", &decode_multibase_data(model).unwrap())
373 .with_min_controller()
374 .with_min_init()
375 .with_min_event()
376 .build_fencepost();
377 let end = EventId::builder()
378 .with_network(&network)
379 .with_sep("model", &decode_multibase_data(model).unwrap())
380 .with_max_controller()
381 .with_max_init()
382 .with_max_event()
383 .build_fencepost();
384
385 // Setup mock expectations
386 let mut mock_interest = MockAccessInterestStoreTest::new();
387 mock_interest
388 .expect_insert()
389 .with(predicate::eq(
390 Interest::builder()
391 .with_sep_key("model")
392 .with_peer_id(&node_id.peer_id())
393 .with_range((start.as_slice(), end.as_slice()))
394 .with_not_after(0)
395 .build(),
396 ))
397 .times(1)
398 .returning(|_| Ok(true));
399 let mock_event_store = MockEventStoreTest::new();
400 let server = create_test_server(
401 node_id,
402 network,
403 mock_interest,
404 Arc::new(mock_event_store),
405 MockP2PService::new(),
406 None,
407 );
408 let interest = models::Interest {
409 sep: "model".to_string(),
410 sep_value: model.to_owned(),
411 controller: None,
412 stream_id: None,
413 };
414 let resp = server.interests_post(interest, &Context).await.unwrap();
415 assert_eq!(resp, InterestsPostResponse::Success);
416}
417
418#[test(tokio::test)]
419

Callers

nothing calls this directly

Calls 15

decode_multibase_dataFunction · 0.85
newFunction · 0.85
create_test_serverFunction · 0.85
with_min_eventMethod · 0.80
with_min_initMethod · 0.80
with_min_controllerMethod · 0.80
with_networkMethod · 0.80
unwrapMethod · 0.80
with_max_eventMethod · 0.80
with_max_initMethod · 0.80
with_max_controllerMethod · 0.80
with_not_afterMethod · 0.80

Tested by

no test coverage detected