diff --git a/tests/e2e/bond/query.go b/tests/e2e/bond/query.go new file mode 100644 index 00000000..8c48b6e8 --- /dev/null +++ b/tests/e2e/bond/query.go @@ -0,0 +1,49 @@ +package bond + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + + bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond" + "git.vdb.to/cerc-io/laconic2d/x/bond/client/cli" +) + +func (ets *E2ETestSuite) TestGetQueryBondList() { + val := ets.network.Validators[0] + sr := ets.Require() + + testCases := []struct { + name string + args []string + createBond bool + preRun func() + }{ + { + "create and get bond lists", + []string{fmt.Sprintf("--%s=json", flags.FlagOutput)}, + true, + func() { + ets.createBond() + }, + }, + } + + for _, tc := range testCases { + ets.Run(fmt.Sprintf("Case %s", tc.name), func() { + clientCtx := val.ClientCtx + if tc.createBond { + tc.preRun() + } + + cmd := cli.GetQueryBondList() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + sr.NoError(err) + var queryResponse bondtypes.QueryGetBondsResponse + err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse) + sr.NoError(err) + sr.NotZero(len(queryResponse.GetBonds())) + }) + } +} diff --git a/tests/e2e/bond/suite.go b/tests/e2e/bond/suite.go index 816abc6c..ce355443 100644 --- a/tests/e2e/bond/suite.go +++ b/tests/e2e/bond/suite.go @@ -107,7 +107,7 @@ func (ets *E2ETestSuite) createBond() string { // getting the bonds list and returning the bond-id clientCtx := val.ClientCtx - cmd := cli.GetQueryBondLists() + cmd := cli.GetQueryBondList() args = []string{ fmt.Sprintf("--%s=json", flags.FlagOutput), } diff --git a/tests/e2e/bond/tx.go b/tests/e2e/bond/tx.go new file mode 100644 index 00000000..edb3a031 --- /dev/null +++ b/tests/e2e/bond/tx.go @@ -0,0 +1,63 @@ +package bond + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + + "git.vdb.to/cerc-io/laconic2d/x/bond/client/cli" +) + +func (ets *E2ETestSuite) TestTxCreateBond() { + val := ets.network.Validators[0] + sr := ets.Require() + + testCases := []struct { + name string + args []string + err bool + }{ + { + "without deposit", + []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), + fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", ets.cfg.BondDenom)), + }, + true, + }, + { + "create bond", + []string{ + fmt.Sprintf("10%s", ets.cfg.BondDenom), + fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), + fmt.Sprintf("--%s=json", flags.FlagOutput), + fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", ets.cfg.BondDenom)), + }, + false, + }, + } + + for _, tc := range testCases { + ets.Run(fmt.Sprintf("Case %s", tc.name), func() { + clientCtx := val.ClientCtx + cmd := cli.NewCreateBondCmd() + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.err { + sr.Error(err) + } else { + sr.NoError(err) + var d sdk.TxResponse + err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d) + sr.Nil(err) + sr.NoError(err) + sr.Zero(d.Code) + } + }) + } +} diff --git a/x/bond/client/cli/query.go b/x/bond/client/cli/query.go index 9a08e15e..019c7d05 100644 --- a/x/bond/client/cli/query.go +++ b/x/bond/client/cli/query.go @@ -12,8 +12,8 @@ import ( bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond" ) -// GetQueryBondLists implements the bond lists query command. -func GetQueryBondLists() *cobra.Command { +// GetQueryBondList implements the bond lists query command. +func GetQueryBondList() *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List bonds.",