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 25, 2020
1 parent 7e230cb commit e093e3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ serde_json = "1"
futures = "0.3"

near-logger-utils = { path = "./test-utils/logger" }
near-actix-utils = { path = "./utils/actix" }
near-chain-configs = { path = "./core/chain-configs" }
near-crypto = { path = "./core/crypto" }
near-primitives = { path = "./core/primitives" }
Expand Down
25 changes: 24 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,
10000,
)
.start();
})
.unwrap();
}
ProcessNodeState::Running(_) => panic!("Node is already running"),
}
Expand Down Expand Up @@ -123,6 +144,8 @@ impl ProcessNode {
"neard",
"--bin",
"neard",
"--features",
"expensive_tests",
"--",
"--home",
&self.work_dir,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_rejoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ mod test {

fn test_kill_1(num_nodes: usize, num_trials: usize, two_shards: bool, test_prefix: &str) {
warmup();
near_actix_utils::init_stop_on_panic();

// Start all nodes, crash node#2, proceed, restart node #2 but crash node #3
let crash1 = 2;
let crash2 = 3;
Expand Down

0 comments on commit e093e3f

Please sign in to comment.