diff options
| author | mat <github@matdoes.dev> | 2022-10-07 23:56:23 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-07 23:56:23 -0500 |
| commit | 6f6289376a0d9ffe7e58506824e37f6b380961c3 (patch) | |
| tree | 97956fc560b338fbef630f0d0617a248e0e8b336 /azalea-protocol/src/lib.rs | |
| parent | e9d8d0357ee63cce321e177bf19a8974699894ee (diff) | |
| download | azalea-drasl-6f6289376a0d9ffe7e58506824e37f6b380961c3.tar.xz | |
fix errors with rewritten packet reading
i forgot i never tested it before LMAO
Diffstat (limited to 'azalea-protocol/src/lib.rs')
| -rwxr-xr-x | azalea-protocol/src/lib.rs | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs index 4da2ba90..58ffac0a 100755 --- a/azalea-protocol/src/lib.rs +++ b/azalea-protocol/src/lib.rs @@ -1,5 +1,9 @@ //! This lib is responsible for parsing Minecraft packets. +// these two are necessary for thiserror backtraces +#![feature(error_generic_member_access)] +#![feature(provide_any)] + use std::net::IpAddr; use std::str::FromStr; @@ -78,12 +82,10 @@ mod tests { } .get(); let mut stream = Vec::new(); - write_packet(packet, &mut stream, None, &mut None) + write_packet(&packet, &mut stream, None, &mut None) .await .unwrap(); - println!("stream: {stream:?}"); - let mut stream = Cursor::new(stream); let _ = read_packet::<ServerboundLoginPacket, _>( @@ -95,4 +97,35 @@ mod tests { .await .unwrap(); } + + #[tokio::test] + async fn test_double_hello_packet() { + let packet = ServerboundHelloPacket { + username: "test".to_string(), + public_key: Some(ProfilePublicKeyData { + expires_at: 0, + key: b"idontthinkthisreallymattersijustwantittobelongforthetest".to_vec(), + key_signature: b"idontthinkthisreallymattersijustwantittobelongforthetest".to_vec(), + }), + profile_id: Some(Uuid::from_u128(0)), + } + .get(); + let mut stream = Vec::new(); + write_packet(&packet, &mut stream, None, &mut None) + .await + .unwrap(); + write_packet(&packet, &mut stream, None, &mut None) + .await + .unwrap(); + let mut stream = Cursor::new(stream); + + let mut buffer = BytesMut::new(); + + let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None) + .await + .unwrap(); + let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None) + .await + .unwrap(); + } } |
