Add a test for params gRPC request

This commit is contained in:
Prathamesh Musale 2024-03-01 14:56:08 +05:30
parent b57ca60277
commit eefaa42eec
3 changed files with 36 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import (
func TestE2ETestSuite(t *testing.T) { func TestE2ETestSuite(t *testing.T) {
cfg := network.DefaultConfig(e2e.NewTestNetworkFixture) cfg := network.DefaultConfig(e2e.NewTestNetworkFixture)
cfg.NumValidators = 2 cfg.NumValidators = 1
suite.Run(t, NewE2ETestSuite(cfg)) suite.Run(t, NewE2ETestSuite(cfg))
} }

26
tests/e2e/auction/grpc.go Normal file
View File

@ -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, &params)
sr.NoError(err)
sr.Equal(*params.GetParams(), auctiontypes.DefaultParams())
})
}

View File

@ -15,16 +15,18 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/staking"
laconicApp "git.vdb.to/cerc-io/laconic2d/app" 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" auctionmodule "git.vdb.to/cerc-io/laconic2d/x/auction/module"
bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module" bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module"
registrymodule "git.vdb.to/cerc-io/laconic2d/x/registry/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 { func NewTestNetworkFixture() network.TestFixture {
dir, err := os.MkdirTemp("", "simapp") dir, err := os.MkdirTemp("", "laconic")
if err != nil { if err != nil {
panic(fmt.Sprintf("failed creating temporary directory: %v", err)) panic(fmt.Sprintf("failed creating temporary directory: %v", err))
} }
@ -50,11 +52,15 @@ func NewTestNetworkFixture() network.TestFixture {
return app return app
} }
// Update prefixes
params.SetAddressPrefixes()
return network.TestFixture{ return network.TestFixture{
AppConstructor: appCtr, AppConstructor: appCtr,
GenesisState: app.DefaultGenesis(), GenesisState: app.DefaultGenesis(),
EncodingConfig: testutil.MakeTestEncodingConfig( EncodingConfig: testutil.MakeTestEncodingConfig(
auth.AppModuleBasic{}, auth.AppModuleBasic{},
staking.AppModuleBasic{},
auctionmodule.AppModule{}, auctionmodule.AppModule{},
bondmodule.AppModule{}, bondmodule.AppModule{},
registrymodule.AppModule{}, registrymodule.AppModule{},