From e1128887548b77808145e1c7d672d971db13f45e Mon Sep 17 00:00:00 2001 From: 0xmuralik Date: Fri, 4 Nov 2022 17:16:42 +0530 Subject: [PATCH] grpc tests --- x/nameservice/keeper/grpc_query_test.go | 42 ++++++++++++++----------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/x/nameservice/keeper/grpc_query_test.go b/x/nameservice/keeper/grpc_query_test.go index ac7348cb..62db2b1d 100644 --- a/x/nameservice/keeper/grpc_query_test.go +++ b/x/nameservice/keeper/grpc_query_test.go @@ -197,12 +197,16 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() { func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() { grpcClient, ctx := suite.queryClient, suite.ctx sr := suite.Require() + examples := []string{ + "/../helpers/examples/service_provider_example.yml", + "/../helpers/examples/website_registration_example.yml", + } testCases := []struct { - msg string - req *nameservicetypes.GetNameServiceModuleBalanceRequest - createRecord bool - expErr bool - noOfRecords int + msg string + req *nameservicetypes.GetNameServiceModuleBalanceRequest + createRecords bool + expErr bool + noOfRecords int }{ { "Get Module Balance", @@ -214,20 +218,22 @@ func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() { } for _, test := range testCases { suite.Run(fmt.Sprintf("Case %s ", test.msg), func() { - if test.createRecord { + if test.createRecords { dir, err := os.Getwd() sr.NoError(err) - payloadType, err := cli.GetPayloadFromFile(dir + "/../helpers/examples/example1.yml") - sr.NoError(err) - payload, err := payloadType.ToPayload() - sr.NoError(err) - record, err := suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{ - BondId: suite.bond.GetId(), - Signer: suite.accounts[0].String(), - Payload: payload, - }) - sr.NoError(err) - sr.NotNil(record.ID) + for _, example := range examples { + payloadType, err := cli.GetPayloadFromFile(fmt.Sprint(dir, example)) + sr.NoError(err) + payload, err := payloadType.ToPayload() + sr.NoError(err) + record, err := suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{ + BondId: suite.bond.GetId(), + Signer: suite.accounts[0].String(), + Payload: payload, + }) + sr.NoError(err) + sr.NotNil(record.ID) + } } resp, err := grpcClient.GetNameServiceModuleBalance(context.Background(), test.req) if test.expErr { @@ -235,7 +241,7 @@ func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() { } else { sr.NoError(err) sr.Equal(test.noOfRecords, len(resp.GetBalances())) - if test.createRecord { + if test.createRecords { balance := resp.GetBalances()[0] sr.Equal(balance.AccountName, nameservicetypes.RecordRentModuleAccountName) }