Skip to content

Commit

Permalink
Add Reply serialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Feb 1, 2024
1 parent 4ed2bb3 commit d992b04
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions types/submessages_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package types

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/require"
)

func TestReplySerialization(t *testing.T) {
reply1 := Reply{
GasUsed: 4312324,
ID: 75,
Result: SubMsgResult{
Ok: &SubMsgResponse{
Events: []Event{
{
Type: "hi",
Attributes: []EventAttribute{
{
Key: "si",
Value: "claro",
},
},
},
},
Data: []byte{0x3f, 0x00, 0xaa, 0x5c, 0xab},
},
},
}
serialized, err := json.Marshal(&reply1)
require.NoError(t, err)
require.Equal(t, `{"gas_used":4312324,"id":75,"result":{"ok":{"events":[{"type":"hi","attributes":[{"key":"si","value":"claro"}]}],"data":"PwCqXKs="}}}`, string(serialized))
}

0 comments on commit d992b04

Please sign in to comment.