From eefaa42eeca2f7ffb295866fe842074d9f971076 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 1 Mar 2024 14:56:08 +0530 Subject: [PATCH] Add a test for params gRPC request --- tests/e2e/auction/cli_test.go | 3 ++- tests/e2e/auction/grpc.go | 26 ++++++++++++++++++++++++++ tests/e2e/common.go | 10 ++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tests/e2e/auction/grpc.go diff --git a/tests/e2e/auction/cli_test.go b/tests/e2e/auction/cli_test.go index 6fe03c4d..2ba78f32 100644 --- a/tests/e2e/auction/cli_test.go +++ b/tests/e2e/auction/cli_test.go @@ -11,6 +11,7 @@ import ( func TestE2ETestSuite(t *testing.T) { cfg := network.DefaultConfig(e2e.NewTestNetworkFixture) - cfg.NumValidators = 2 + cfg.NumValidators = 1 + suite.Run(t, NewE2ETestSuite(cfg)) } diff --git a/tests/e2e/auction/grpc.go b/tests/e2e/auction/grpc.go new file mode 100644 index 00000000..332bc103 --- /dev/null +++ b/tests/e2e/auction/grpc.go @@ -0,0 +1,26 @@ +package auction + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/testutil" + + auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction" +) + +func (ets *E2ETestSuite) TestQueryParamsGrpc() { + val := ets.network.Validators[0] + sr := ets.Require() + reqURL := fmt.Sprintf("%s/cerc/auction/v1/params", val.APIAddress) + + ets.Run("valid request to get auction params", func() { + resp, err := testutil.GetRequest(reqURL) + ets.Require().NoError(err) + + var params auctiontypes.QueryParamsResponse + err = val.ClientCtx.Codec.UnmarshalJSON(resp, ¶ms) + + sr.NoError(err) + sr.Equal(*params.GetParams(), auctiontypes.DefaultParams()) + }) +} diff --git a/tests/e2e/common.go b/tests/e2e/common.go index 5d446527..12adbffc 100644 --- a/tests/e2e/common.go +++ b/tests/e2e/common.go @@ -15,16 +15,18 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/staking" laconicApp "git.vdb.to/cerc-io/laconic2d/app" + "git.vdb.to/cerc-io/laconic2d/app/params" auctionmodule "git.vdb.to/cerc-io/laconic2d/x/auction/module" bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module" registrymodule "git.vdb.to/cerc-io/laconic2d/x/registry/module" ) -// NewTestNetworkFixture returns a new simapp AppConstructor for network simulation tests +// NewTestNetworkFixture returns a new LaconicApp AppConstructor for network simulation tests func NewTestNetworkFixture() network.TestFixture { - dir, err := os.MkdirTemp("", "simapp") + dir, err := os.MkdirTemp("", "laconic") if err != nil { panic(fmt.Sprintf("failed creating temporary directory: %v", err)) } @@ -50,11 +52,15 @@ func NewTestNetworkFixture() network.TestFixture { return app } + // Update prefixes + params.SetAddressPrefixes() + return network.TestFixture{ AppConstructor: appCtr, GenesisState: app.DefaultGenesis(), EncodingConfig: testutil.MakeTestEncodingConfig( auth.AppModuleBasic{}, + staking.AppModuleBasic{}, auctionmodule.AppModule{}, bondmodule.AppModule{}, registrymodule.AppModule{},