Skip to content

Commit

Permalink
hack: set_receipient earlier to avoid a race condition
Browse files Browse the repository at this point in the history
It seems that we have a race-condition pre-existing on master:

```diff
diff --git a/tools/mock_node/src/setup.rs b/tools/mock_node/src/setup.rs
index 501722c07..0378cf0f9 100644
--- a/tools/mock_node/src/setup.rs
+++ b/tools/mock_node/src/setup.rs
@@ -342,6 +342,7 @@ pub fn setup_mock_node(
     #[cfg(feature = "test_features")]
     let server = None;

+    std::thread::sleep_ms(300);
     network_adapter.set_recipient(mock_network_actor.clone().recipient());
     (mock_network_actor, client_actor, view_client, server)
 }
```

and then

```
$ cargo test -p mock_node --lib -- test_mock_node_basic
```

fail for me.

THe current actix upgrade seems to exacebrate the issues, alegedly
because start_http now takes longer.

Work-around this by tying the know earlier.
  • Loading branch information
matklad committed May 18, 2022
1 parent f6cd804 commit b7e844a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions nearcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ pub fn start_with_config_and_synchronization(
)
.unwrap()
});
network_adapter.set_recipient(network_actor.recipient());

#[cfg(feature = "json_rpc")]
if let Some(rpc_config) = config.rpc_config {
Expand Down Expand Up @@ -351,8 +352,6 @@ pub fn start_with_config_and_synchronization(
));
}

network_adapter.set_recipient(network_actor.recipient());

rpc_servers.shrink_to_fit();

trace!(target: "diagnostic", key="log", "Starting NEAR node with diagnostic activated");
Expand Down
2 changes: 1 addition & 1 deletion tools/mock_node/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ pub fn setup_mock_node(
!archival,
)
});
network_adapter.set_recipient(mock_network_actor.clone().recipient());

// for some reason, with "test_features", start_http requires PeerManagerActor,
// we are not going to run start_mock_network with test_features, so let's disable that for now
Expand All @@ -342,7 +343,6 @@ pub fn setup_mock_node(
#[cfg(feature = "test_features")]
let server = None;

network_adapter.set_recipient(mock_network_actor.clone().recipient());
(mock_network_actor, client_actor, view_client, server)
}

Expand Down

0 comments on commit b7e844a

Please sign in to comment.