Dump packet with ByteBufInPacket toString

This commit is contained in:
P0nk
2021-08-23 20:59:51 +02:00
parent da2d8abc56
commit 4fd7adf547
2 changed files with 34 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package net.packet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.opcodes.SendOpcode;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -189,4 +190,18 @@ class ByteBufInPacketTest {
assertArrayEquals(bytes, sameBytes);
}
@Test
void toString_shouldIncludeEntirePacket() {
OutPacket outPacket = OutPacket.create(SendOpcode.COCONUT_HIT);
outPacket.writeByte(111);
ByteBuf byteBuf = Unpooled.wrappedBuffer(outPacket.getBytes());
ByteBufInPacket inPacket = new ByteBufInPacket(byteBuf);
String initial = inPacket.toString();
inPacket.readShort();
String afterReadingOpcode = inPacket.toString();
assertEquals(initial.length(), afterReadingOpcode.length());
}
}