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/mine_block_without_rollback.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/mine_block_without_rollback.rs')
| -rw-r--r-- | azalea-client/tests/simulation/mine_block_without_rollback.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/azalea-client/tests/simulation/mine_block_without_rollback.rs b/azalea-client/tests/simulation/mine_block_without_rollback.rs new file mode 100644 index 00000000..71f360c4 --- /dev/null +++ b/azalea-client/tests/simulation/mine_block_without_rollback.rs @@ -0,0 +1,46 @@ +use azalea_client::{mining::StartMiningBlockEvent, test_utils::prelude::*}; +use azalea_core::position::{BlockPos, ChunkPos}; +use azalea_protocol::packets::{ + ConnectionProtocol, + game::{ClientboundBlockChangedAck, ClientboundBlockUpdate}, +}; +use azalea_registry::builtin::BlockKind; + +#[test] +fn test_mine_block_without_rollback() { + let _lock = init(); + + let mut simulation = Simulation::new(ConnectionProtocol::Game); + simulation.receive_packet(default_login_packet()); + + simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16)); + simulation.tick(); + + let pos = BlockPos::new(1, 2, 3); + simulation.receive_packet(ClientboundBlockUpdate { + pos, + // tnt is used for this test because it's insta-mineable so we don't have to waste ticks + // waiting + block_state: BlockKind::Tnt.into(), + }); + simulation.tick(); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Tnt.into())); + + simulation.write_message(StartMiningBlockEvent { + entity: simulation.entity, + position: pos, + force: true, + }); + simulation.tick(); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Air.into())); + + // server acknowledged our change by sending a BlockUpdate + BlockChangedAck, so + // no rollback + simulation.receive_packet(ClientboundBlockUpdate { + pos, + block_state: BlockKind::Air.into(), + }); + simulation.receive_packet(ClientboundBlockChangedAck { seq: 1 }); + simulation.tick(); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Air.into())); +} |
