aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/test_utils
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-client/src/test_utils')
-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)]