aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/tests/simulation/mine_block_without_rollback.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-12-22 21:43:54 -1400
committermat <git@matdoes.dev>2025-12-22 21:43:54 -1400
commit82e3d46ca319badcbc584cf902aeebcbd30948b9 (patch)
tree4afb8c6135caacbdf9f1f04d451cb2bae1c488b6 /azalea-client/tests/simulation/mine_block_without_rollback.rs
parent0429a81d706da7c45600d357f9f9a14cef6113b4 (diff)
downloadazalea-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.rs46
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()));
+}