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

fix: Fix Evidence CLI query flag parsing #13458

Merged
merged 12 commits into from
Nov 2, 2022
Merged
8 changes: 6 additions & 2 deletions x/evidence/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"context"
"encoding/base64"
"encoding/hex"
"fmt"
"strings"
Expand Down Expand Up @@ -32,7 +33,6 @@ $ %s query %s --page=2 --limit=50
),
),
Args: cobra.MaximumNArgs(1),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: QueryEvidenceCmd(),
}
Expand Down Expand Up @@ -72,7 +72,11 @@ func queryEvidence(clientCtx client.Context, hash string) error {

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryEvidenceRequest{EvidenceHash: decodedHash}
a, _ := base64.StdEncoding.DecodeString(hash)
Fixed Show fixed Hide fixed
fmt.Println("decoded hash and a : ", decodedHash, a)

params := &types.QueryEvidenceRequest{EvidenceHash: a}

res, err := queryClient.Evidence(context.Background(), params)
if err != nil {
return err
Expand Down
19 changes: 18 additions & 1 deletion x/evidence/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"
"testing"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
Expand All @@ -17,6 +16,9 @@ import (
coretypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client/flags"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
Expand Down Expand Up @@ -99,6 +101,21 @@ func TestGetQueryCmd(t *testing.T) {
"evidence: []\npagination: null",
false,
},
"all evidence(json output)": {
facundomedica marked this conversation as resolved.
Show resolved Hide resolved
[]string{
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
func() client.Context {
bz, _ := encCfg.Codec.Marshal(&sdk.TxResponse{})
c := newMockTendermintRPC(abci.ResponseQuery{
Value: bz,
})
return baseCtx.WithClient(c)
},
"",
`{"evidence":[],"pagination":null}`,
false,
},
}

for name, tc := range testCases {
Expand Down