Skip to content

Commit

Permalink
fix(test): fix test_4_20_kill1
Browse files Browse the repository at this point in the history
Fixes #3141

Test plan
---------
test_4_20_kill1
  • Loading branch information
mikhailOK committed Aug 24, 2020
1 parent 7e230cb commit 792145e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test-utils/testlib/src/node/process_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use neard::config::NearConfig;
use crate::node::Node;
use crate::user::rpc_user::RpcUser;
use crate::user::User;
use actix::{Actor, System};
use futures::{FutureExt, TryFutureExt};
use near_jsonrpc_client::new_client;
use near_network::test_utils::WaitOrTimeout;

pub enum ProcessNodeState {
Stopped,
Expand Down Expand Up @@ -46,7 +50,24 @@ impl Node for ProcessNode {
let child =
self.get_start_node_command().spawn().expect("start node command failed");
self.state = ProcessNodeState::Running(child);
thread::sleep(Duration::from_secs(3));
let addr = self.config.rpc_config.addr.clone();

System::run(|| {
WaitOrTimeout::new(
Box::new(move |_| {
actix::spawn(
new_client(&format!("http://{}", addr))
.status()
.map_ok(|_| System::current().stop())
.map(drop),
)
}),
500,
5000,
)
.start();
})
.unwrap();
}
ProcessNodeState::Running(_) => panic!("Node is already running"),
}
Expand Down

0 comments on commit 792145e

Please sign in to comment.