Add a CLI tests for create and list bond commands
All checks were successful
Integration Tests / test-integration (pull_request) Successful in 2m4s
All checks were successful
Integration Tests / test-integration (pull_request) Successful in 2m4s
This commit is contained in:
parent
19da88254e
commit
a763d53a3c
49
tests/e2e/bond/query.go
Normal file
49
tests/e2e/bond/query.go
Normal file
@ -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()))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -107,7 +107,7 @@ func (ets *E2ETestSuite) createBond() string {
|
|||||||
|
|
||||||
// getting the bonds list and returning the bond-id
|
// getting the bonds list and returning the bond-id
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetQueryBondLists()
|
cmd := cli.GetQueryBondList()
|
||||||
args = []string{
|
args = []string{
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
}
|
}
|
||||||
|
63
tests/e2e/bond/tx.go
Normal file
63
tests/e2e/bond/tx.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,8 @@ import (
|
|||||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetQueryBondLists implements the bond lists query command.
|
// GetQueryBondList implements the bond lists query command.
|
||||||
func GetQueryBondLists() *cobra.Command {
|
func GetQueryBondList() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List bonds.",
|
Short: "List bonds.",
|
||||||
|
Loading…
Reference in New Issue
Block a user