diff --git a/ably/internal/ablyutil/msgpack.go b/ably/internal/ablyutil/msgpack.go index 98dd66ce..b0ad4462 100644 --- a/ably/internal/ablyutil/msgpack.go +++ b/ably/internal/ablyutil/msgpack.go @@ -12,7 +12,6 @@ var handle codec.MsgpackHandle func init() { handle.Raw = true handle.WriteExt = true - handle.RawToString = true } // UnmarshalMsgpack decodes the MessagePack-encoded data and stores the result in the diff --git a/ably/internal/ablyutil/msgpack_test.go b/ably/internal/ablyutil/msgpack_test.go index 59e98cef..3bec4e32 100644 --- a/ably/internal/ablyutil/msgpack_test.go +++ b/ably/internal/ablyutil/msgpack_test.go @@ -5,9 +5,25 @@ package ablyutil import ( "bytes" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "testing" ) +func TestUnmarshallByte(t *testing.T) { + buf := []byte{ + 0xc4, // bin8 + 2, // len + 'a', 'a', // bytes + } + var target interface{} + + err := UnmarshalMsgpack(buf, &target) + require.NoError(t, err) + assert.IsType(t, []byte{}, target, + "bin8 should be decoded as []byte, but instead we got %T", target) +} + func TestMsgpack(t *testing.T) { type Object1 struct { Key int64 `codec:"my_key"`