From 1cdefeaa9286a0942a6f7025f41d0c345ba9987f Mon Sep 17 00:00:00 2001 From: Yongwoo Lee Date: Thu, 14 May 2020 10:08:37 +0900 Subject: [PATCH] feat: add codespace to broadcast response (#6) --- types/result_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/types/result_test.go b/types/result_test.go index 03a6b61875..faeb353799 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -215,3 +215,25 @@ func TestWrapServiceResult(t *testing.T) { require.NoError(t, err) require.Equal(t, spot, spot2) } + +func TestNewResponseFormatBroadcastTx(t *testing.T) { + hash, err := hex.DecodeString("00000000000000000000000000000000") + require.NoError(t, err) + result := ctypes.ResultBroadcastTx{ + Code: 1, + Data: []byte("some data"), + Log: `[{"log":"","msg_index":1,"success":true}]`, + Codespace: "codespace", + Hash: hash, + } + + txResponse := sdk.NewResponseFormatBroadcastTx(&result) + + require.NoError(t, err) + require.Equal(t, result.Code, txResponse.Code) + require.Equal(t, result.Data.String(), txResponse.Data) + require.NotEmpty(t, txResponse.Logs) + require.Equal(t, result.Log, txResponse.RawLog) + require.Equal(t, result.Codespace, txResponse.Codespace) + require.Equal(t, result.Hash.String(), txResponse.TxHash) +}