package ll import ( "bytes" "testing" "github.com/stretchr/testify/require" ) func TestEncode(t *testing.T) { buf := &bytes.Buffer{} enc := NewEncoder(buf) require.Nil(t, enc.Encode(&Msg{ Type: MsgTypeHsRequest, Data: []byte{0x12, 0x34}, })) require.Equal(t, []byte{'D', 'J', 'R', 0x01, 0x00, 0x08, 0x12, 0x34}, buf.Bytes()) }