Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: generalize query response with height #4573

Merged
merged 19 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert indenting to two spaces
  • Loading branch information
colin-axner committed Jun 21, 2019
commit cc115ef7d4e1cf1870932e9d797d218a7727a175
4 changes: 2 additions & 2 deletions types/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func PostProcessResponse(w http.ResponseWriter, cliCtx context.CLIContext, respo
default:
var err error
if cliCtx.Indent {
output, err = cliCtx.Codec.MarshalJSONIndent(response, "", " ")
output, err = cliCtx.Codec.MarshalJSONIndent(response, "", " ")
} else {
output, err = cliCtx.Codec.MarshalJSON(response)
}
Expand All @@ -267,7 +267,7 @@ func PostProcessResponse(w http.ResponseWriter, cliCtx context.CLIContext, respo
m["height"] = height

if cliCtx.Indent {
output, err = json.MarshalIndent(m, "", " ")
output, err = json.MarshalIndent(m, "", " ")
} else {
output, err = json.Marshal(m)
}
Expand Down
9 changes: 5 additions & 4 deletions types/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package rest

import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -165,7 +166,7 @@ func TestProcessPostResponse(t *testing.T) {
jsonNoHeight, err := cdc.MarshalJSON(acc)
require.Nil(t, err)
require.NotNil(t, jsonNoHeight)
jsonIndentNoHeight, err := cdc.MarshalJSONIndent(acc, "", " ")
jsonIndentNoHeight, err := cdc.MarshalJSONIndent(acc, "", " ")
require.Nil(t, err)
require.NotNil(t, jsonIndentNoHeight)

Expand All @@ -176,8 +177,8 @@ func TestProcessPostResponse(t *testing.T) {
jsonMap, err := json.Marshal(m)
require.Nil(t, err)
jsonWithHeight := append(append([]byte(`{"height":`), []byte(strconv.Itoa(int(height))+",")...), jsonMap[1:]...)
jsonIndentMap, err := json.MarshalIndent(m, "", " ")
jsonIndentWithHeight := append(append([]byte(`{`+"\n "+`"height": `), []byte(strconv.Itoa(int(height))+",")...), jsonIndentMap[1:]...)
jsonIndentMap, err := json.MarshalIndent(m, "", " ")
jsonIndentWithHeight := append(append([]byte(`{`+"\n "+` "height": `), []byte(strconv.Itoa(int(height))+",")...), jsonIndentMap[1:]...)

// check that negative height writes an error
w := httptest.NewRecorder()
Expand Down Expand Up @@ -215,7 +216,7 @@ func runPostProcessResponse(t *testing.T, ctx context.CLIContext, obj interface{

var marshalled []byte
if indent {
marshalled, err = ctx.Codec.MarshalJSONIndent(obj, "", " ")
marshalled, err = ctx.Codec.MarshalJSONIndent(obj, "", " ")
} else {
marshalled, err = ctx.Codec.MarshalJSON(obj)
}
Expand Down