package proxy import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "mpbl3p/mocks" "testing" ) func TestPacket_Marshal(t *testing.T) { testContent := []byte("A test string is the content of this packet.") testPacket := NewPacket(testContent) testMac := mocks.AlmostUselessMac{} t.Run("Length", func(t *testing.T) { marshalled := testPacket.Marshal(testMac) assert.Len(t, marshalled, len(testContent)+8+4) }) } func TestUnmarshalPacket(t *testing.T) { testContent := []byte("A test string is the content of this packet.") testPacket := NewPacket(testContent) testMac := mocks.AlmostUselessMac{} testMarshalled := testPacket.Marshal(testMac) t.Run("Length", func(t *testing.T) { p, err := UnmarshalPacket(testMarshalled, testMac) require.Nil(t, err) assert.Len(t, p.Raw(), len(testContent)) }) }