MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / test_reorder

Function test_reorder

flow-rs/src/node/reorder.rs:85–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 use rand::seq::SliceRandom;
84 #[flow_rs::rt::test]
85 async fn test_reorder() {
86 let reorder = Sandbox::pure("Reorder").unwrap();
87 let input = reorder.input("inp").unwrap();
88 let output = reorder.output("out").unwrap();
89 let handle = reorder.start();
90 let send_fut = async move {
91 let mut rng: StdRng = SeedableRng::from_entropy();
92 let mut list: Vec<u64> = (0..10).collect();
93 list[..].shuffle(&mut rng);
94 for i in list {
95 let mut envelope = Envelope::new(0usize).seal();
96 envelope.info_mut().partial_id = Some(i);
97 input.send_any(envelope).await.ok();
98 }
99 input.close();
100 };
101
102 let recv_fut = async move {
103 let mut seq_id = 0;
104 while let Ok(msg) = output.recv_any().await {
105 assert_eq!(msg.info().partial_id, Some(seq_id));
106 seq_id += 1;
107 }
108 };
109
110 join!(send_fut, recv_fut);
111
112 handle.await.unwrap();
113 }
114}

Callers

nothing calls this directly

Calls 8

sealMethod · 0.80
send_anyMethod · 0.80
recv_anyMethod · 0.80
inputMethod · 0.45
outputMethod · 0.45
startMethod · 0.45
info_mutMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected