diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 78747de69..19eb2e2b3 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -401,15 +401,22 @@ func TestTxs(t *testing.T) { // query wrong res, body := Request(t, port, "GET", "/txs", nil) - // TODO: test empty array response + require.Equal(t, http.StatusOK, res.StatusCode, body) + require.Equal(t, "\"[]\"", body) // query empty res, body = Request(t, port, "GET", fmt.Sprintf("/txs?sender_bech32=%s", "cosmos1jawd35d9aq4u76sr3fjalmcqc8hqygs90d0g0v"), nil) - require.Equal(t, "", body) + require.Equal(t, http.StatusOK, res.StatusCode, body) + require.Equal(t, "\"[]\"", body) res, body = Request(t, port, "GET", fmt.Sprintf("/txs?action=submit-proposal&proposer=%s", "cosmos1jawd35d9aq4u76sr3fjalmcqc8hqygs90d0g0v"), nil) + require.Equal(t, http.StatusOK, res.StatusCode, body) + require.Equal(t, "\"[]\"", body) + // also tests url decoding res, body = Request(t, port, "GET", fmt.Sprintf("/txs?action=submit%%20proposal&proposer=%s", "cosmos1jawd35d9aq4u76sr3fjalmcqc8hqygs90d0g0v"), nil) + require.Equal(t, http.StatusOK, res.StatusCode, body) + require.Equal(t, "\"[]\"", body) // create TX receiveAddr, resultTx := doSend(t, port, seed, name, password, addr) @@ -431,10 +438,9 @@ func TestTxs(t *testing.T) { // XXX should this move into some other testfile for txs in general? // test if created TX hash is the correct hash - // assert.Equal(t, resultTx.Hash, indexedTxs[0].Hash) + require.Equal(t, resultTx.Hash, indexedTxs[0].Hash) // query sender - // also tests url decoding res, body = Request(t, port, "GET", fmt.Sprintf("/txs?sender_bech32=%s", addr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) diff --git a/client/tx/search.go b/client/tx/search.go index f94fd9fff..a3d037a01 100644 --- a/client/tx/search.go +++ b/client/tx/search.go @@ -146,6 +146,7 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http. return } if len(r.Form) == 0 { + utils.PostProcessResponse(w, cdc, "[]", cliCtx.Indent) return } @@ -171,7 +172,6 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http. tags = append(tags, tag) } - // txs, err := searchTxs(cliCtx, cdc, tags) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) @@ -179,6 +179,7 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http. } if len(txs) == 0 { + utils.PostProcessResponse(w, cdc, "[]", cliCtx.Indent) return }