aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/test_utils/simulation.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-09-20 20:35:16 -1200
committermat <git@matdoes.dev>2025-09-20 20:35:16 -1200
commit585b51e91a5335eae37bc5af7c0111bb2092b156 (patch)
treec1559014df9db20dd625d9fe972d4e9f88317008 /azalea-client/src/test_utils/simulation.rs
parentdb793448ff8e656ad80859835edc3b89cb547dd2 (diff)
downloadazalea-drasl-585b51e91a5335eae37bc5af7c0111bb2092b156.tar.xz
more accurate mining and impl PartialEq for packets
Diffstat (limited to 'azalea-client/src/test_utils/simulation.rs')
-rw-r--r--azalea-client/src/test_utils/simulation.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/azalea-client/src/test_utils/simulation.rs b/azalea-client/src/test_utils/simulation.rs
index a763962b..aa3cef1b 100644
--- a/azalea-client/src/test_utils/simulation.rs
+++ b/azalea-client/src/test_utils/simulation.rs
@@ -232,9 +232,22 @@ impl SentPackets {
panic!("Expected {expected_formatted}, got nothing");
}
}
+
+ pub fn maybe_expect(&self, check: impl FnOnce(&ServerboundGamePacket) -> bool) {
+ let sent_packet = self.peek();
+ if let Some(sent_packet) = sent_packet
+ && check(&sent_packet)
+ {
+ self.next();
+ }
+ }
+
pub fn next(&self) -> Option<ServerboundGamePacket> {
self.list.lock().pop_front()
}
+ pub fn peek(&self) -> Option<ServerboundGamePacket> {
+ self.list.lock().front().cloned()
+ }
}
#[allow(clippy::type_complexity)]