laconicd/tests/e2e/bond/query.go
Prathamesh Musale d346b95234 Add e2e tests for gRPC requests and CLI commands (#13)
- Add E2E tests following pattern suggested in cosmos-sdk docs:
  https://docs.cosmos.network/v0.50/build/building-modules/testing#end-to-end-tests
  - Tests for gRPC requests
  - Tests for manually configured CLI commands
- Add a CI workflow to run these E2E tests

Reviewed-on: deep-stack/laconic2d#13
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-03-04 11:16:09 +00:00

50 lines
1.0 KiB
Go

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()))
})
}
}