Skip to content

Commit

Permalink
BevyRenet: fix sometimes failing to connect in test
Browse files Browse the repository at this point in the history
Updating only 3 time to connect may fail since we don't control the system order for the server/client update.  Update a few more times to make sure the connection is established.
  • Loading branch information
lucaspoffo committed Nov 18, 2022
1 parent 2e41366 commit 7bb390f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions bevy_renet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ renet = { path = "../renet", version = "0.0.9" }
serde = { version = "1.0", features = [ "derive" ] }
bevy = { version = "0.8.0", default-features = false, features = ["bevy_core_pipeline", "bevy_render", "bevy_asset", "bevy_pbr", "x11"] }
bincode = "1.3.1"
env_logger = "0.9.0"
8 changes: 5 additions & 3 deletions bevy_renet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ mod tests {

#[test]
fn sending_and_receiving_messages() {
env_logger::init();
let server = create_server().unwrap();
let client = create_client().unwrap();

Expand All @@ -156,9 +157,10 @@ mod tests {
.insert_resource(server)
.insert_resource(client);

app.update();
app.update();
app.update();
// Connect client
for _ in 0..10 {
app.update();
}

let client = app.world.resource::<RenetClient>();
assert!(client.is_connected(), "The client should be connected to the server",);
Expand Down

0 comments on commit 7bb390f

Please sign in to comment.