Skip to content

Commit

Permalink
ci: fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Sep 25, 2021
1 parent fadc662 commit 3bc0036
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions tentacle/src/service/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub enum TargetProtocol {
/// Try open one protocol
Single(ProtocolId),
/// Try open some protocol, if return true, open it
Filter(Box<dyn Fn(&ProtocolId) -> bool + Send>),
Filter(Box<dyn Fn(&ProtocolId) -> bool + Sync + Send + 'static>),
}

impl From<ProtocolId> for TargetProtocol {
Expand All @@ -143,7 +143,7 @@ pub enum TargetSession {
/// Try send to only one
Single(SessionId),
/// Try send to some session, if return true, send to it
Filter(Box<dyn Fn(&SessionId) -> bool + Send>),
Filter(Box<dyn Fn(&SessionId) -> bool + Sync + Send + 'static>),
}

impl From<SessionId> for TargetSession {
Expand Down
38 changes: 19 additions & 19 deletions tentacle/tests/test_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ fn test(secio: bool, shutdown: bool) {

let (addr_sender, addr_receiver) = channel::<Multiaddr>();

let handle = thread::spawn(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
let rt = tokio::runtime::Runtime::new().unwrap();
let async_handle = rt.handle().clone();

let handle = thread::spawn(move || {
async_handle.block_on(async move {
let listen_addr = service_1
.listen("/ip4/127.0.0.1/tcp/0".parse().unwrap())
.await
Expand All @@ -151,32 +153,30 @@ fn test(secio: bool, shutdown: bool) {
let listen_addr_3 = listen_addr.clone();
let listen_addr_4 = listen_addr.clone();

start_service(service_2, listen_addr_2);
start_service(service_3, listen_addr_3);
start_service(service_4, listen_addr_4);
start_service(service_5, listen_addr);
let async_handle = rt.handle();
start_service(service_2, listen_addr_2, async_handle);
start_service(service_3, listen_addr_3, async_handle);
start_service(service_4, listen_addr_4, async_handle);
start_service(service_5, listen_addr, async_handle);

handle.join().expect("test fail");
}

fn start_service<F>(
mut service: Service<F>,
listen_addr: Multiaddr,
) -> ::std::thread::JoinHandle<()>
where
handle: &tokio::runtime::Handle,
) where
F: ServiceHandle + Unpin + Send + 'static,
{
thread::spawn(move || {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
service
.dial(listen_addr, TargetProtocol::All)
.await
.unwrap();
handle.spawn(async move {
service
.dial(listen_addr, TargetProtocol::All)
.await
.unwrap();

service.run().await
});
})
service.run().await;
});
}

#[test]
Expand Down

0 comments on commit 3bc0036

Please sign in to comment.