diff --git a/x/stakers/keeper/exported_functions_test.go b/x/stakers/keeper/exported_functions_test.go index 3bb9fa44..05acfa2c 100644 --- a/x/stakers/keeper/exported_functions_test.go +++ b/x/stakers/keeper/exported_functions_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + pooltypes "github.com/KYVENetwork/chain/x/pool/types" "strconv" kyveApp "github.com/KYVENetwork/chain/app" @@ -14,8 +15,7 @@ import ( delegationTypes "github.com/KYVENetwork/chain/x/delegation/types" // Gov govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - // Pool - poolTypes "github.com/KYVENetwork/chain/x/pool/types" + // Stakers stakersTypes "github.com/KYVENetwork/chain/x/stakers/types" ) @@ -56,15 +56,14 @@ var _ = Describe("Protocol Governance Voting", Ordered, func() { _ = s.RunTxSuccess(createTx) // Create and join a pool. - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "Cosmos Hub", - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) joinTx := &stakersTypes.MsgJoinPool{ Creator: i.ALICE, diff --git a/x/stakers/keeper/msg_server_join_pool_test.go b/x/stakers/keeper/msg_server_join_pool_test.go index 841327b5..47f99a6a 100644 --- a/x/stakers/keeper/msg_server_join_pool_test.go +++ b/x/stakers/keeper/msg_server_join_pool_test.go @@ -46,20 +46,20 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { initialBalanceStaker1 := uint64(0) initialBalanceValaddress1 := uint64(0) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create pool - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // create staker s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ @@ -174,16 +174,17 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { It("Join disabled pool", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "DisabledPool", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - Disabled: true, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) + + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + pool.Disabled = true + s.App().PoolKeeper.SetPool(s.Ctx(), pool) // ACT _, err := s.RunTx(&stakerstypes.MsgJoinPool{ @@ -392,15 +393,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Amount: 100 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ @@ -417,15 +416,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { It("Try to join pool with a valaddress that is already used by another staker", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ Creator: i.STAKER_1, @@ -488,15 +485,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Amount: 100 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // ACT s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ diff --git a/x/stakers/keeper/msg_server_leave_pool_test.go b/x/stakers/keeper/msg_server_leave_pool_test.go index bc05b851..788ca95e 100644 --- a/x/stakers/keeper/msg_server_leave_pool_test.go +++ b/x/stakers/keeper/msg_server_leave_pool_test.go @@ -23,21 +23,20 @@ TEST CASES - msg_server_leave_pool.go var _ = Describe("msg_server_leave_pool.go", Ordered, func() { s := i.NewCleanChain() + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create pool - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // create staker s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ @@ -208,15 +207,13 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { It("Leave one of multiple pools a staker has previously joined", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0,