Dump packet with ByteBufInPacket toString
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user