From d992b04828e757e087c0ecf1596ed88a69fd3394 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 29 Jan 2024 11:55:34 +0100 Subject: [PATCH] Add Reply serialization test --- types/submessages_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 types/submessages_test.go diff --git a/types/submessages_test.go b/types/submessages_test.go new file mode 100644 index 000000000..336ce1cdc --- /dev/null +++ b/types/submessages_test.go @@ -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)) +}