diff options
| author | mat <git@matdoes.dev> | 2025-12-22 21:43:54 -1400 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-12-22 21:43:54 -1400 |
| commit | 82e3d46ca319badcbc584cf902aeebcbd30948b9 (patch) | |
| tree | 4afb8c6135caacbdf9f1f04d451cb2bae1c488b6 /azalea-client/tests/simulation/ticks_alive.rs | |
| parent | 0429a81d706da7c45600d357f9f9a14cef6113b4 (diff) | |
| download | azalea-drasl-82e3d46ca319badcbc584cf902aeebcbd30948b9.tar.xz | |
run azalea-client integration tests as one binary
per https://corrode.dev/blog/tips-for-faster-rust-compile-times/\#combine-all-integration-tests-into-a-single-binary <3
Diffstat (limited to 'azalea-client/tests/simulation/ticks_alive.rs')
| -rw-r--r-- | azalea-client/tests/simulation/ticks_alive.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/azalea-client/tests/simulation/ticks_alive.rs b/azalea-client/tests/simulation/ticks_alive.rs new file mode 100644 index 00000000..655504db --- /dev/null +++ b/azalea-client/tests/simulation/ticks_alive.rs @@ -0,0 +1,32 @@ +use azalea_client::{test_utils::prelude::*, tick_counter::TicksConnected}; +use azalea_protocol::packets::ConnectionProtocol; + +#[test] +fn counter_increments_and_resets_on_disconnect() { + let _lock = init(); + + let mut simulation = Simulation::new(ConnectionProtocol::Game); + simulation.tick(); + + assert!(!simulation.has_component::<TicksConnected>()); + simulation.receive_packet(default_login_packet()); + simulation.tick(); + + assert!(simulation.has_component::<TicksConnected>()); + assert_eq!(simulation.component::<TicksConnected>().0, 1); + + // Tick three times; counter should read 2, 3, 4. + for expected in 2..=4 { + simulation.tick(); + let counter = simulation.component::<TicksConnected>(); + assert_eq!( + counter.0, expected, + "after {expected} tick(s) counter should be {expected}" + ); + } + + simulation.disconnect(); + simulation.tick(); + + assert!(!simulation.has_component::<TicksConnected>()); +} |
