github.com/Tri-stone/burrow@v0.25.0/execution/names/names_test.go (about) 1 package names 2 3 import ( 4 "testing" 5 6 "github.com/gogo/protobuf/proto" 7 "github.com/hyperledger/burrow/crypto" 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestEncodeAmino(t *testing.T) { 13 entry := &Entry{ 14 Name: "Foo", 15 Data: "oh noes", 16 Expires: 24423432, 17 Owner: crypto.Address{1, 2, 0, 9, 8, 8, 1, 2}, 18 } 19 encoded, err := entry.Encode() 20 require.NoError(t, err) 21 entryOut, err := DecodeEntry(encoded) 22 require.NoError(t, err) 23 assert.Equal(t, entry, entryOut) 24 } 25 26 func TestEncodeProtobuf(t *testing.T) { 27 entry := &Entry{ 28 Name: "Foo", 29 Data: "oh noes", 30 Expires: 24423432, 31 Owner: crypto.Address{1, 2, 0, 9, 8, 8, 1, 2}, 32 } 33 encoded, err := proto.Marshal(entry) 34 require.NoError(t, err) 35 entryOut := new(Entry) 36 err = proto.Unmarshal(encoded, entryOut) 37 require.NoError(t, err) 38 assert.Equal(t, entry, entryOut) 39 }