update cli tests
This commit is contained in:
parent
8a95de4086
commit
ee4c51bb36
|
@ -35,16 +35,15 @@ passed to the --tags option. To match any transaction, use the --any option.
|
|||
|
||||
For example:
|
||||
|
||||
$ gaiacli tendermint txs --tag test1,test2
|
||||
$ gaiacli query txs --tag test1,test2
|
||||
|
||||
will match any transaction tagged with both test1,test2. To match a transaction tagged with either
|
||||
test1 or test2, use:
|
||||
|
||||
$ gaiacli tendermint txs --tag test1,test2 --any
|
||||
$ gaiacli query txs --tag test1,test2 --any
|
||||
`),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
tags := viper.GetStringSlice(flagTags)
|
||||
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
|
||||
txs, err := searchTxs(cliCtx, cdc, tags)
|
||||
|
@ -140,13 +139,14 @@ func FormatTxResults(cdc *codec.Codec, res []*ctypes.ResultTx) ([]Info, error) {
|
|||
func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var tags []string
|
||||
var txs []Info
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusBadRequest, sdk.AppendMsgToErr("could not parse query parameters", err.Error()))
|
||||
return
|
||||
}
|
||||
if len(r.Form) == 0 {
|
||||
utils.PostProcessResponse(w, cdc, "[]", cliCtx.Indent)
|
||||
utils.PostProcessResponse(w, cdc, txs, cliCtx.Indent)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -166,13 +166,23 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.
|
|||
}
|
||||
|
||||
key = strings.TrimRight(key, "_bech32")
|
||||
value = sdk.AccAddress(bz).String()
|
||||
if prefix == sdk.Bech32PrefixAccAddr {
|
||||
value = sdk.AccAddress(bz).String()
|
||||
} else if prefix == sdk.Bech32PrefixValAddr {
|
||||
value = sdk.ValAddress(bz).String()
|
||||
} else {
|
||||
utils.WriteErrorResponse(w, http.StatusBadRequest,
|
||||
sdk.ErrInvalidAddress(fmt.Sprintf("invalid bech32 prefix '%s'", prefix)).Error(),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
tag := fmt.Sprintf("%s='%s'", key, value)
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
txs, err := searchTxs(cliCtx, cdc, tags)
|
||||
txs, err = searchTxs(cliCtx, cdc, tags)
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
|
@ -354,6 +355,10 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|||
executeWrite(t, spStr, app.DefaultKeyPass)
|
||||
tests.WaitForNextNBlocksTM(2, port)
|
||||
|
||||
// Test query txs
|
||||
// txs := executeGetTxs(t, fmt.Sprintf("gaiacli query txs --tag action=submit-proposal,proposer=%s %v", fooAddr, flags))
|
||||
// require.Len(t, txs, 1)
|
||||
|
||||
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
||||
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||
|
||||
|
@ -728,6 +733,18 @@ func executeGetAccount(t *testing.T, cmdStr string) auth.BaseAccount {
|
|||
return acc
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// txs
|
||||
|
||||
func executeGetTxs(t *testing.T, cmdStr string) []tx.Info {
|
||||
out, _ := tests.ExecuteT(t, cmdStr, "")
|
||||
var txs []tx.Info
|
||||
cdc := app.MakeCodec()
|
||||
err := cdc.UnmarshalJSON([]byte(out), &txs)
|
||||
require.NoError(t, err, "out %v\n, err %v", out, err)
|
||||
return txs
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// stake
|
||||
|
||||
|
|
Loading…
Reference in New Issue