Skip to content

Commit

Permalink
fix: tests in x/query
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Oct 3, 2023
1 parent 0c0cec8 commit 5961096
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 50 deletions.
29 changes: 13 additions & 16 deletions x/query/keeper/grpc_account_redelegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ var _ = Describe("grpc_account_redelegation.go", Ordered, func() {
BeforeEach(func() {
s = i.NewCleanChain()

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "T",
// create 2 pools
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
msg := &pooltypes.MsgCreatePool{
Authority: gov,
MinDelegation: 200 * i.KYVE,
UploadInterval: 60,
MaxBundleSize: 100,
Protocol: &pooltypes.Protocol{},
UpgradePlan: &pooltypes.UpgradePlan{},
})
Binaries: "{}",
}
s.RunTxPoolSuccess(msg)
s.RunTxPoolSuccess(msg)

// disable second pool
pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1)
pool.Disabled = true
s.App().PoolKeeper.SetPool(s.Ctx(), pool)

s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{
Creator: i.STAKER_0,
Expand All @@ -47,17 +55,6 @@ var _ = Describe("grpc_account_redelegation.go", Ordered, func() {
Amount: 100 * i.KYVE,
})

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "DisabledPool",
Protocol: &pooltypes.Protocol{
Version: "0.0.0",
Binaries: "{}",
LastUpgrade: uint64(s.Ctx().BlockTime().Unix()),
},
Disabled: true,
UpgradePlan: &pooltypes.UpgradePlan{},
})

s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{
Creator: i.STAKER_1,
PoolId: 0,
Expand Down
28 changes: 18 additions & 10 deletions x/query/keeper/grpc_query_can_propose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
i "github.com/KYVENetwork/chain/testutil/integration"
bundletypes "github.com/KYVENetwork/chain/x/bundles/types"
delegationtypes "github.com/KYVENetwork/chain/x/delegation/types"
funderstypes "github.com/KYVENetwork/chain/x/funders/types"
pooltypes "github.com/KYVENetwork/chain/x/pool/types"
querytypes "github.com/KYVENetwork/chain/x/query/types"
stakertypes "github.com/KYVENetwork/chain/x/stakers/types"
Expand Down Expand Up @@ -38,19 +39,26 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() {
BeforeEach(func() {
s = i.NewCleanChain()

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "PoolTest",
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
msg := &pooltypes.MsgCreatePool{
Authority: gov,
MinDelegation: 200 * i.KYVE,
UploadInterval: 60,
MaxBundleSize: 100,
Protocol: &pooltypes.Protocol{},
UpgradePlan: &pooltypes.UpgradePlan{},
})
Binaries: "{}",
}
s.RunTxPoolSuccess(msg)

s.RunTxPoolSuccess(&pooltypes.MsgFundPool{
s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{
Creator: i.ALICE,
Id: 0,
Amount: 100 * i.KYVE,
Moniker: "Alice",
})

s.RunTxFundersSuccess(&funderstypes.MsgFundPool{
Creator: i.ALICE,
PoolId: 0,
Amount: 100 * i.KYVE,
AmountPerBundle: 1 * i.KYVE,
})

s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{
Expand Down Expand Up @@ -518,9 +526,9 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() {

It("Call can propose on an active pool without funds as the next uploader with valid args", func() {
// ARRANGE
s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{
s.RunTxPoolSuccess(&funderstypes.MsgDefundPool{
Creator: i.ALICE,
Id: 0,
PoolId: 0,
Amount: 100 * i.KYVE,
})

Expand Down
22 changes: 8 additions & 14 deletions x/query/keeper/grpc_query_can_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() {
BeforeEach(func() {
s = i.NewCleanChain()

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "PoolTest",
// create 2 pools
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
msg := &pooltypes.MsgCreatePool{
Authority: gov,
MinDelegation: 200 * i.KYVE,
UploadInterval: 60,
MaxBundleSize: 100,
Protocol: &pooltypes.Protocol{},
UpgradePlan: &pooltypes.UpgradePlan{},
})
Binaries: "{}",
}
s.RunTxPoolSuccess(msg)
s.RunTxPoolSuccess(msg)

s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{
Creator: i.STAKER_0,
Expand All @@ -50,15 +53,6 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() {
Amount: 0,
})

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "Test Pool2",
MinDelegation: 200 * i.KYVE,
UploadInterval: 60,
MaxBundleSize: 100,
Protocol: &pooltypes.Protocol{},
UpgradePlan: &pooltypes.UpgradePlan{},
})

s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{
Creator: i.STAKER_1,
Amount: 100 * i.KYVE,
Expand Down
28 changes: 18 additions & 10 deletions x/query/keeper/grpc_query_can_vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
i "github.com/KYVENetwork/chain/testutil/integration"
bundletypes "github.com/KYVENetwork/chain/x/bundles/types"
delegationtypes "github.com/KYVENetwork/chain/x/delegation/types"
funderstypes "github.com/KYVENetwork/chain/x/funders/types"
pooltypes "github.com/KYVENetwork/chain/x/pool/types"
querytypes "github.com/KYVENetwork/chain/x/query/types"
stakertypes "github.com/KYVENetwork/chain/x/stakers/types"
Expand Down Expand Up @@ -39,19 +40,26 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() {
BeforeEach(func() {
s = i.NewCleanChain()

s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{
Name: "PoolTest",
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
msg := &pooltypes.MsgCreatePool{
Authority: gov,
MinDelegation: 200 * i.KYVE,
UploadInterval: 60,
MaxBundleSize: 100,
Protocol: &pooltypes.Protocol{},
UpgradePlan: &pooltypes.UpgradePlan{},
})
Binaries: "{}",
}
s.RunTxPoolSuccess(msg)

s.RunTxPoolSuccess(&pooltypes.MsgFundPool{
s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{
Creator: i.ALICE,
Id: 0,
Amount: 100 * i.KYVE,
Moniker: "Alice",
})

s.RunTxPoolSuccess(&funderstypes.MsgFundPool{
Creator: i.ALICE,
PoolId: 0,
Amount: 100 * i.KYVE,
AmountPerBundle: 1 * i.KYVE,
})

s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{
Expand Down Expand Up @@ -467,9 +475,9 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() {

It("Call can vote on an active pool with no funds and a data bundle with valid args", func() {
// ARRANGE
s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{
s.RunTxPoolSuccess(&funderstypes.MsgDefundPool{
Creator: i.ALICE,
Id: 0,
PoolId: 0,
Amount: 100 * i.KYVE,
})

Expand Down

0 comments on commit 5961096

Please sign in to comment.