Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: remove near_actix_test_utils::run_actix_until_panic #4452

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions chain/client/tests/bug_repros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use actix::{Addr, System};
use futures::FutureExt;
use rand::{thread_rng, Rng};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_chain::test_utils::account_id_to_shard_id;
use near_client::test_utils::setup_mock_all_validators;
use near_client::{ClientActor, GetBlock, ViewClientActor};
Expand All @@ -24,7 +24,7 @@ use near_primitives::transaction::SignedTransaction;
fn repro_1183() {
let validator_groups = 2;
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -146,7 +146,7 @@ fn test_sync_from_achival_node() {
let blocks = Arc::new(RwLock::new(HashMap::new()));
let epoch_length = 4;

run_actix_until_stop(async move {
run_actix(async move {
let network_mock: Arc<
RwLock<Box<dyn FnMut(String, &NetworkRequests) -> (NetworkResponses, bool)>>,
> = Arc::new(RwLock::new(Box::new(|_: String, _: &NetworkRequests| {
Expand Down Expand Up @@ -242,7 +242,7 @@ fn test_long_gap_between_blocks() {
let epoch_length = 1000;
let target_height = 600;

run_actix_until_stop(async move {
run_actix(async move {
let network_mock: Arc<
RwLock<Box<dyn FnMut(String, &NetworkRequests) -> (NetworkResponses, bool)>>,
> = Arc::new(RwLock::new(Box::new(|_: String, _: &NetworkRequests| {
Expand Down
12 changes: 6 additions & 6 deletions chain/client/tests/catching_up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod tests {
use borsh::{BorshDeserialize, BorshSerialize};
use futures::{future, FutureExt};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_chain::test_utils::account_id_to_shard_id;
use near_chain_configs::TEST_STATE_SYNC_TIMEOUT;
use near_client::test_utils::setup_mock_all_validators;
Expand Down Expand Up @@ -121,7 +121,7 @@ mod tests {
fn test_catchup_receipts_sync_common(wait_till: u64, send: u64, sync_hold: bool) {
let validator_groups = 1;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -400,7 +400,7 @@ mod tests {
fn test_catchup_random_single_part_sync_common(skip_15: bool, non_zero: bool, height: u64) {
let validator_groups = 2;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -611,7 +611,7 @@ mod tests {
fn test_catchup_sanity_blocks_produced() {
let validator_groups = 2;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -692,7 +692,7 @@ mod tests {
fn test_chunk_grieving() {
let validator_groups = 1;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -862,7 +862,7 @@ mod tests {
) {
let validator_groups = 1;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down
14 changes: 7 additions & 7 deletions chain/client/tests/chunks_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use actix::{Addr, System};
use futures::{future, FutureExt};
use log::info;

use near_actix_test_utils::{run_actix_until_panic, run_actix_until_stop};
use near_actix_test_utils::run_actix;
use near_chain::ChainGenesis;
use near_chunks::{
CHUNK_REQUEST_RETRY_MS, CHUNK_REQUEST_SWITCH_TO_FULL_FETCH_MS,
Expand All @@ -33,7 +33,7 @@ use testlib::test_helpers::heavy_test;
#[test]
fn chunks_produced_and_distributed_all_in_all_shards() {
heavy_test(|| {
run_actix_until_stop(async {
run_actix(async {
chunks_produced_and_distributed_common(1, false, 15 * CHUNK_REQUEST_RETRY_MS);
});
});
Expand All @@ -42,7 +42,7 @@ fn chunks_produced_and_distributed_all_in_all_shards() {
#[test]
fn chunks_produced_and_distributed_2_vals_per_shard() {
heavy_test(|| {
run_actix_until_stop(async {
run_actix(async {
chunks_produced_and_distributed_common(2, false, 15 * CHUNK_REQUEST_RETRY_MS);
});
});
Expand All @@ -51,7 +51,7 @@ fn chunks_produced_and_distributed_2_vals_per_shard() {
#[test]
fn chunks_produced_and_distributed_one_val_per_shard() {
heavy_test(|| {
run_actix_until_stop(async {
run_actix(async {
chunks_produced_and_distributed_common(4, false, 15 * CHUNK_REQUEST_RETRY_MS);
});
});
Expand All @@ -65,7 +65,7 @@ fn chunks_produced_and_distributed_one_val_per_shard() {
#[test]
fn chunks_recovered_from_others() {
heavy_test(|| {
run_actix_until_stop(async {
run_actix(async {
chunks_produced_and_distributed_common(2, true, 4 * CHUNK_REQUEST_SWITCH_TO_OTHERS_MS);
});
});
Expand All @@ -79,7 +79,7 @@ fn chunks_recovered_from_others() {
#[should_panic]
fn chunks_recovered_from_full_timeout_too_short() {
heavy_test(|| {
run_actix_until_panic(async {
run_actix(async {
chunks_produced_and_distributed_common(4, true, 2 * CHUNK_REQUEST_SWITCH_TO_OTHERS_MS);
});
});
Expand All @@ -90,7 +90,7 @@ fn chunks_recovered_from_full_timeout_too_short() {
#[test]
fn chunks_recovered_from_full() {
heavy_test(|| {
run_actix_until_stop(async {
run_actix(async {
chunks_produced_and_distributed_common(
4,
true,
Expand Down
4 changes: 2 additions & 2 deletions chain/client/tests/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod tests {
use actix::{Addr, System};
use rand::{thread_rng, Rng};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_chain::Block;
use near_client::test_utils::setup_mock_all_validators;
use near_client::{ClientActor, ViewClientActor};
Expand All @@ -27,7 +27,7 @@ mod tests {

const HEIGHT_GOAL: u64 = 120;

run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));
let connectors1 = connectors.clone();
Expand Down
8 changes: 4 additions & 4 deletions chain/client/tests/cross_shard_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::{Arc, RwLock};
use actix::{Addr, System};
use futures::{future, FutureExt};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_client::test_utils::setup_mock_all_validators;
use near_client::{ClientActor, Query, ViewClientActor};
use near_logger_utils::init_integration_logger;
Expand All @@ -18,7 +18,7 @@ fn test_keyvalue_runtime_balances() {
let validator_groups = 2;
let successful_queries = Arc::new(AtomicUsize::new(0));
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down Expand Up @@ -86,7 +86,7 @@ mod tests {
use actix::{Addr, MailboxError, System};
use futures::{future, FutureExt};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_chain::test_utils::account_id_to_shard_id;
use near_client::test_utils::{setup_mock_all_validators, BlockStats};
use near_client::{ClientActor, Query, ViewClientActor};
Expand Down Expand Up @@ -394,7 +394,7 @@ mod tests {
) {
let validator_groups = 4;
init_integration_logger();
run_actix_until_stop(async move {
run_actix(async move {
let connectors: Arc<RwLock<Vec<(Addr<ClientActor>, Addr<ViewClientActor>)>>> =
Arc::new(RwLock::new(vec![]));

Expand Down
20 changes: 10 additions & 10 deletions chain/client/tests/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use actix::System;
use futures::{future, FutureExt};
use num_rational::Rational;

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_chain::chain::NUM_EPOCHS_TO_KEEP_STORE_DATA;
use near_chain::types::LatestKnown;
use near_chain::validate::validate_chunk_with_chunk_extra;
Expand Down Expand Up @@ -170,7 +170,7 @@ fn prepare_env_with_congestion(
#[test]
fn produce_two_blocks() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let count = Arc::new(AtomicUsize::new(0));
setup_mock(
vec!["test"],
Expand Down Expand Up @@ -198,7 +198,7 @@ fn produce_two_blocks() {
fn produce_blocks_with_tx() {
let mut encoded_chunks: Vec<EncodedShardChunk> = vec![];
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let (client, view_client) = setup_mock(
vec!["test"],
"test",
Expand Down Expand Up @@ -263,7 +263,7 @@ fn produce_blocks_with_tx() {
#[test]
fn receive_network_block() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
// The first header announce will be when the block is received. We don't immediately endorse
// it. The second header announce will happen with the endorsement a little later.
let first_header_announce = Arc::new(RwLock::new(true));
Expand Down Expand Up @@ -330,7 +330,7 @@ fn produce_block_with_approvals() {
let validators = vec![
"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10",
];
run_actix_until_stop(async {
run_actix(async {
let (client, view_client) = setup_mock(
validators.clone(),
"test1",
Expand Down Expand Up @@ -424,7 +424,7 @@ fn produce_block_with_approvals_arrived_early() {
let key_pairs =
vec![PeerInfo::random(), PeerInfo::random(), PeerInfo::random(), PeerInfo::random()];
let block_holder: Arc<RwLock<Option<Block>>> = Arc::new(RwLock::new(None));
run_actix_until_stop(async move {
run_actix(async move {
let mut approval_counter = 0;
let network_mock: Arc<
RwLock<Box<dyn FnMut(String, &NetworkRequests) -> (NetworkResponses, bool)>>,
Expand Down Expand Up @@ -495,7 +495,7 @@ fn produce_block_with_approvals_arrived_early() {
/// and that the node bans the peer for invalid block header.
fn invalid_blocks_common(is_requested: bool) {
init_test_logger();
run_actix_until_stop(async move {
run_actix(async move {
let mut ban_counter = 0;
let (client, view_client) = setup_mock(
vec!["test"],
Expand Down Expand Up @@ -638,7 +638,7 @@ fn ban_peer_for_invalid_block_common(mode: InvalidBlockMode) {
let validators = vec![vec!["test1", "test2", "test3", "test4"]];
let key_pairs =
vec![PeerInfo::random(), PeerInfo::random(), PeerInfo::random(), PeerInfo::random()];
run_actix_until_stop(async move {
run_actix(async move {
let mut ban_counter = 0;
let network_mock: Arc<
RwLock<Box<dyn FnMut(String, &NetworkRequests) -> (NetworkResponses, bool)>>,
Expand Down Expand Up @@ -776,7 +776,7 @@ fn test_ban_peer_for_ill_formed_block() {
#[test]
fn skip_block_production() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
setup_mock(
vec!["test1", "test2"],
"test2",
Expand All @@ -802,7 +802,7 @@ fn skip_block_production() {
#[test]
fn client_sync_headers() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let peer_info1 = PeerInfo::random();
let peer_info2 = peer_info1.clone();
let (client, _) = setup_mock(
Expand Down
10 changes: 5 additions & 5 deletions chain/client/tests/query_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use actix::System;
use futures::{future, FutureExt};

use chrono::Utc;
use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_client::test_utils::{setup, setup_no_network};
use near_client::{
GetBlock, GetBlockWithMerkleTree, GetExecutionOutcomesForBlock, Query, Status, TxStatus,
Expand All @@ -27,7 +27,7 @@ use std::time::Duration;
#[test]
fn query_client() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let (_, view_client) = setup_no_network(vec!["test"], "other", true, true);
actix::spawn(
view_client
Expand All @@ -52,7 +52,7 @@ fn query_client() {
#[test]
fn query_status_not_crash() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let (client, view_client) = setup_no_network(vec!["test"], "other", true, false);
let signer = InMemoryValidatorSigner::from_seed("test", KeyType::ED25519, "test");
actix::spawn(view_client.send(GetBlockWithMerkleTree::latest()).then(move |res| {
Expand Down Expand Up @@ -107,7 +107,7 @@ fn query_status_not_crash() {
#[test]
fn test_execution_outcome_for_chunk() {
init_test_logger();
run_actix_until_stop(async {
run_actix(async {
let (client, view_client) = setup_no_network(vec!["test"], "test", true, false);
let signer = InMemorySigner::from_seed("test", KeyType::ED25519, "test");

Expand Down Expand Up @@ -171,7 +171,7 @@ fn test_execution_outcome_for_chunk() {

#[test]
fn test_state_request() {
run_actix_until_stop(async {
run_actix(async {
let (_, _, view_client) = setup(
vec![vec!["test"]],
1,
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ macro_rules! test_with_client {
($node_type:expr, $client:ident, $block:expr) => {
init_test_logger();

run_actix_until_stop(|| {
run_actix(|| {
let (_view_client_addr, addr) = test_utils::start_all($node_type);

let $client = new_client(&format!("http://{}", addr));
Expand Down
4 changes: 2 additions & 2 deletions chain/jsonrpc/tests/http_query.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use actix::System;
use futures::{future, FutureExt};

use near_actix_test_utils::run_actix_until_stop;
use near_actix_test_utils::run_actix;
use near_jsonrpc::client::new_http_client;
use near_logger_utils::init_test_logger;

Expand All @@ -12,7 +12,7 @@ pub mod test_utils;
fn test_status() {
init_test_logger();

run_actix_until_stop(async {
run_actix(async {
let (_view_client_addr, addr) = test_utils::start_all(test_utils::NodeType::NonValidator);

let client = new_http_client(&format!("http://{}", addr));
Expand Down
Loading