aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-09-01 20:37:38 -0500
committermat <github@matdoes.dev>2022-09-01 20:37:38 -0500
commit32458d743f757da3193717fe5554f490703640c0 (patch)
treed0e655ac09195c41f6f7d44462d28aab4d1183db /azalea-protocol/src/packets
parent4d072d8057518fe233b8e7390f6c1f4c54b1cfc0 (diff)
downloadazalea-drasl-32458d743f757da3193717fe5554f490703640c0.tar.xz
fix bad u32::write_into and add tests
Diffstat (limited to 'azalea-protocol/src/packets')
-rwxr-xr-xazalea-protocol/src/packets/login/serverbound_hello_packet.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
index 7644beae..a6443737 100755
--- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
@@ -2,16 +2,35 @@ use azalea_buf::McBuf;
use packet_macros::ServerboundLoginPacket;
use uuid::Uuid;
-#[derive(Clone, Debug, McBuf, ServerboundLoginPacket)]
+#[derive(Clone, Debug, ServerboundLoginPacket, McBuf, PartialEq)]
pub struct ServerboundHelloPacket {
pub username: String,
pub public_key: Option<ProfilePublicKeyData>,
pub profile_id: Option<Uuid>,
}
-#[derive(Clone, Debug, McBuf)]
+#[derive(Clone, Debug, McBuf, PartialEq)]
pub struct ProfilePublicKeyData {
pub expires_at: u64,
pub key: Vec<u8>,
pub key_signature: Vec<u8>,
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use azalea_buf::{McBufReadable, McBufWritable};
+
+ #[test]
+ fn test_read_write() {
+ let packet = ServerboundHelloPacket {
+ username: "test".to_string(),
+ public_key: None,
+ profile_id: Some(Uuid::from_u128(0)),
+ };
+ let mut buf = Vec::new();
+ packet.write_into(&mut buf).unwrap();
+ let packet2 = ServerboundHelloPacket::read_from(&mut buf.as_slice()).unwrap();
+ assert_eq!(packet, packet2);
+ }
+}