github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/serializablebytes_test.go (about)

     1  // Copyright (c) 2019 IoTeX Foundation
     2  // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
     3  // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
     4  // This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
     5  
     6  package protocol
     7  
     8  import (
     9  	"bytes"
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func TestSerializableBytes(t *testing.T) {
    16  	require := require.New(t)
    17  	data := []byte("some data")
    18  	var sb SerializableBytes
    19  	require.NoError(sb.Deserialize(data))
    20  	c, err := sb.Serialize()
    21  	require.NoError(err)
    22  	require.True(bytes.Equal(data, c))
    23  }