From 98004d85bca7f85251764ccbec934e6ad9b6d774 Mon Sep 17 00:00:00 2001 From: rapha Date: Thu, 5 Oct 2023 17:38:37 +0200 Subject: [PATCH] fix: pool query checks --- testutil/integration/checks.go | 15 ++++++++++----- testutil/integration/integration.go | 12 ------------ x/delegation/keeper/msg_server_delegate_test.go | 2 ++ x/pool/keeper/msg_server_disable_pool_test.go | 1 - 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index efc0f3db..446fcf29 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -24,11 +24,7 @@ func (suite *KeeperTestSuite) PerformValidityChecks() { // verify pool module suite.VerifyPoolModuleAssetsIntegrity() suite.VerifyPoolTotalFunds() - - if suite.options.VerifyPoolQueries { - suite.VerifyPoolQueries() - } - + suite.VerifyPoolQueries() suite.VerifyPoolGenesisImportExport() // verify stakers module @@ -99,6 +95,15 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() { poolsQuery = append(poolsQuery, activePoolsQuery.Pools...) poolsQuery = append(poolsQuery, disabledPoolsQuery.Pools...) + // sort pools by id + for i := range poolsQuery { + for j := range poolsQuery { + if poolsQuery[i].Id < poolsQuery[j].Id { + poolsQuery[i], poolsQuery[j] = poolsQuery[j], poolsQuery[i] + } + } + } + Expect(activePoolsQueryErr).To(BeNil()) Expect(disabledPoolsQueryErr).To(BeNil()) diff --git a/testutil/integration/integration.go b/testutil/integration/integration.go index 4c1cdd64..2464188d 100644 --- a/testutil/integration/integration.go +++ b/testutil/integration/integration.go @@ -133,10 +133,6 @@ type QueryClients struct { stakersClient stakerstypes.QueryClient } -type KeeperTestSuiteOptions struct { - VerifyPoolQueries bool -} - type KeeperTestSuite struct { suite.Suite @@ -148,7 +144,6 @@ type KeeperTestSuite struct { consAddress sdk.ConsAddress validator stakingtypes.Validator denom string - options KeeperTestSuiteOptions } func (suite *KeeperTestSuite) App() *app.App { @@ -224,13 +219,6 @@ func (suite *KeeperTestSuite) SetupApp(startTime int64) { _ = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) validators := suite.app.StakingKeeper.GetValidators(suite.ctx, 1) suite.validator = validators[0] - suite.options = KeeperTestSuiteOptions{ - VerifyPoolQueries: true, - } -} - -func (suite *KeeperTestSuite) SetOptions(options KeeperTestSuiteOptions) { - suite.options = options } func (suite *KeeperTestSuite) Commit() { diff --git a/x/delegation/keeper/msg_server_delegate_test.go b/x/delegation/keeper/msg_server_delegate_test.go index ebd7705c..3df12833 100644 --- a/x/delegation/keeper/msg_server_delegate_test.go +++ b/x/delegation/keeper/msg_server_delegate_test.go @@ -22,6 +22,7 @@ TEST CASES - msg_server_delegate.go * Don't pay out rewards twice * Delegate to validator with 0 $KYVE * Delegate to multiple validators + */ var _ = Describe("msg_server_delegate.go", Ordered, func() { @@ -267,6 +268,7 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { Expect(charlieDelegation).To(Equal(200 * i.KYVE)) }) + // TODO: delegate to multiple validators It("Delegate to multiple validators", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ diff --git a/x/pool/keeper/msg_server_disable_pool_test.go b/x/pool/keeper/msg_server_disable_pool_test.go index c04b7a1f..25251059 100644 --- a/x/pool/keeper/msg_server_disable_pool_test.go +++ b/x/pool/keeper/msg_server_disable_pool_test.go @@ -41,7 +41,6 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.SetOptions(i.KeeperTestSuiteOptions{VerifyPoolQueries: false}) // create clean pool for every test case s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{