Skip to content

Commit 832e748

Browse files
broker: test: Refactor connect_client() and bump version to 1.15
1 parent 56a7b39 commit 832e748

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

broker/src/broker/test.rs

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -255,24 +255,6 @@ async fn wrong_client_replies_function_call() {
255255
let mut handle = broker.handle().clone();
256256
tokio::spawn(broker.run());
257257

258-
async fn connect_client(broker: &mut BrokerHandle) -> Unbounded {
259-
let (mut t1, t2) = channel::unbounded();
260-
261-
t1.send(Connect::with_serialize_value(14, &()).unwrap().into())
262-
.await
263-
.unwrap();
264-
265-
let conn = broker.connect(t2).await.unwrap();
266-
267-
let Message::ConnectReply(ConnectReply::Ok(_)) = t1.receive().await.unwrap() else {
268-
panic!();
269-
};
270-
271-
tokio::spawn(conn.run());
272-
273-
t1
274-
}
275-
276258
let mut client1 = connect_client(&mut handle).await;
277259
let mut client2 = connect_client(&mut handle).await;
278260

@@ -366,27 +348,6 @@ async fn send_item_without_capacity() {
366348
let mut handle = broker.handle().clone();
367349
tokio::spawn(broker.run());
368350

369-
async fn connect_client(broker: &mut BrokerHandle) -> Unbounded {
370-
let (mut t1, t2) = channel::unbounded();
371-
372-
t1.send(Connect::with_serialize_value(14, &()).unwrap().into())
373-
.await
374-
.unwrap();
375-
376-
let conn = broker.connect(t2).await.unwrap();
377-
378-
if !matches!(
379-
t1.receive().await,
380-
Ok(Message::ConnectReply(ConnectReply::Ok(_)))
381-
) {
382-
panic!();
383-
};
384-
385-
tokio::spawn(conn.run());
386-
387-
t1
388-
}
389-
390351
let mut client1 = connect_client(&mut handle).await;
391352
let mut client2 = connect_client(&mut handle).await;
392353

@@ -509,3 +470,28 @@ async fn calls_from_multiple_clients() {
509470
client3.join().await;
510471
broker.join().await;
511472
}
473+
474+
async fn connect_client(broker: &mut BrokerHandle) -> Unbounded {
475+
const VERSION: ProtocolVersion = ProtocolVersion::V1_15;
476+
477+
let (mut t1, t2) = channel::unbounded();
478+
479+
t1.send(
480+
Connect2::with_serialize_data(VERSION.major(), VERSION.minor(), &ConnectData::new())
481+
.unwrap()
482+
.into(),
483+
)
484+
.await
485+
.unwrap();
486+
487+
let conn = broker.connect(t2).await.unwrap();
488+
489+
let Message::ConnectReply2(reply) = t1.receive().await.unwrap() else {
490+
panic!("expected connect-reply2");
491+
};
492+
493+
assert_eq!(reply.result, ConnectResult::Ok(VERSION.minor()));
494+
495+
tokio::spawn(conn.run());
496+
t1
497+
}

0 commit comments

Comments
 (0)