From d786e8b902e160ac5a466aba9bcddfe25cc6bd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C3=B4ng=20Li=E1=BB=81u?= <93205232+DongLieu@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:25:31 +0700 Subject: [PATCH] Test for Zone (#682) * Test for Zone * lint * minor fix * minor fix follow nhan --------- Co-authored-by: Nguyen Thanh Nhan --- x/interchainstaking/keeper/grpc_query_test.go | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/x/interchainstaking/keeper/grpc_query_test.go b/x/interchainstaking/keeper/grpc_query_test.go index 9dcf51488..cf221ad94 100644 --- a/x/interchainstaking/keeper/grpc_query_test.go +++ b/x/interchainstaking/keeper/grpc_query_test.go @@ -1302,3 +1302,50 @@ func (suite *KeeperTestSuite) TestKeeper_MappedAccounts() { }) } } + +func (suite *KeeperTestSuite) TestKeeper_Zone() { + testCases := []struct { + name string + malleate func() + req *types.QueryZoneRequest + wantErr bool + }{ + { + name: "empty request", + malleate: func() {}, + req: nil, + wantErr: true, + }, + { + name: "zone not found", + malleate: func() {}, + req: &types.QueryZoneRequest{ChainId: suite.chainB.ChainID}, + wantErr: true, + }, + { + name: "zone valid request", + malleate: func() { + suite.SetupTest() + suite.setupTestZones() + }, + req: &types.QueryZoneRequest{ChainId: suite.chainB.ChainID}, + wantErr: false, + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + tc.malleate() + icsKeeper := suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper + ctx := suite.chainA.GetContext() + + resp, err := icsKeeper.Zone(ctx, tc.req) + if tc.wantErr { + suite.T().Logf("Error:\n%v\n", err) + suite.Error(err) + } else { + suite.NoError(err) + suite.NotNil(resp) + } + }) + } +}