Skip to content

Commit

Permalink
test: fixed existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Dec 16, 2024
1 parent 29ff7b0 commit 36f8f16
Show file tree
Hide file tree
Showing 17 changed files with 316 additions and 292 deletions.
4 changes: 2 additions & 2 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() {
for i := range poolsState {
bundleProposalState, _ := suite.App().BundlesKeeper.GetBundleProposal(suite.Ctx(), poolsState[i].Id)
stakersState := suite.App().StakersKeeper.GetAllStakerAddressesOfPool(suite.Ctx(), poolsState[i].Id)
totalDelegationState := suite.App().StakersKeeper.GetDelegationOfPool(suite.Ctx(), poolsState[i].Id)
totalDelegationState := suite.App().StakersKeeper.GetTotalStakeOfPool(suite.Ctx(), poolsState[i].Id)

Expect(poolsQuery[i].Id).To(Equal(poolsState[i].Id))
Expect(*poolsQuery[i].Data).To(Equal(poolsState[i]))
Expand Down Expand Up @@ -175,7 +175,7 @@ func (suite *KeeperTestSuite) VerifyStakersModuleAssetsIntegrity() {
func (suite *KeeperTestSuite) VerifyPoolTotalStake() {
for _, pool := range suite.App().PoolKeeper.GetAllPools(suite.Ctx()) {
expectedBalance := uint64(0)
actualBalance := suite.App().StakersKeeper.GetDelegationOfPool(suite.Ctx(), pool.Id)
actualBalance := suite.App().StakersKeeper.GetTotalStakeOfPool(suite.Ctx(), pool.Id)

for _, stakerAddress := range suite.App().StakersKeeper.GetAllStakerAddressesOfPool(suite.Ctx(), pool.Id) {
expectedBalance += suite.App().StakersKeeper.GetValidatorPoolStake(suite.Ctx(), stakerAddress, pool.Id)
Expand Down
28 changes: 13 additions & 15 deletions x/bundles/keeper/keeper_suite_invalid_bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ var _ = Describe("invalid bundles", Ordered, func() {
}
s.RunTxPoolSuccess(msg)

params := s.App().PoolKeeper.GetParams(s.Ctx())
params.MaxVotingPowerPerPool = math.LegacyMustNewDecFromStr("1")
s.App().PoolKeeper.SetParams(s.Ctx(), params)

s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{
Creator: i.ALICE,
Moniker: "Alice",
Expand Down Expand Up @@ -94,12 +98,6 @@ var _ = Describe("invalid bundles", Ordered, func() {
StakeFraction: math.LegacyMustNewDecFromStr("1"),
})

s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{
Creator: i.VALADDRESS_0_A,
Staker: i.STAKER_0,
PoolId: 0,
})

initialBalanceStaker0 = s.GetBalanceFromAddress(i.STAKER_0)
initialBalanceValaddress0 = s.GetBalanceFromAddress(i.VALADDRESS_0_A)

Expand Down Expand Up @@ -164,8 +162,8 @@ var _ = Describe("invalid bundles", Ordered, func() {
s.CommitAfterSeconds(60)

s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{
Creator: i.VALADDRESS_1_A,
Staker: i.STAKER_1,
Creator: i.VALADDRESS_0_A,
Staker: i.STAKER_0,
PoolId: 0,
StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg",
DataSize: 100,
Expand Down Expand Up @@ -230,7 +228,7 @@ var _ = Describe("invalid bundles", Ordered, func() {
slashAmount := uint64(math.LegacyNewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64())

Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100*i.KYVE - slashAmount))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check voter status
valaccountVoter, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_1)
Expand Down Expand Up @@ -330,8 +328,8 @@ var _ = Describe("invalid bundles", Ordered, func() {
s.CommitAfterSeconds(60)

s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{
Creator: i.VALADDRESS_1_A,
Staker: i.STAKER_1,
Creator: i.VALADDRESS_0_A,
Staker: i.STAKER_0,
PoolId: 0,
StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg",
DataSize: 100,
Expand Down Expand Up @@ -400,7 +398,7 @@ var _ = Describe("invalid bundles", Ordered, func() {
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100*i.KYVE - slashAmountUploader))
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.ALICE)).To(Equal(100*i.KYVE - slashAmountDelegator))

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(400 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(400 * i.KYVE))

// check voter status
valaccountVoter, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_1)
Expand Down Expand Up @@ -526,8 +524,8 @@ var _ = Describe("invalid bundles", Ordered, func() {
s.CommitAfterSeconds(60)

s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{
Creator: i.VALADDRESS_3_A,
Staker: i.STAKER_3,
Creator: i.VALADDRESS_0_A,
Staker: i.STAKER_0,
PoolId: 0,
StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg",
DataSize: 100,
Expand Down Expand Up @@ -604,7 +602,7 @@ var _ = Describe("invalid bundles", Ordered, func() {
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(100*i.KYVE - slashAmountVoter))
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.BOB)).To(Equal(100*i.KYVE - slashAmountDelegator2))

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(450 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(450 * i.KYVE))

// check voter status
_, voterActive := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_1)
Expand Down
12 changes: 6 additions & 6 deletions x/bundles/keeper/keeper_suite_stakers_leave_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var _ = Describe("stakers leave", Ordered, func() {
_, valaccountActive := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_0)
Expect(valaccountActive).To(BeFalse())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader got not slashed
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100 * i.KYVE))
Expand Down Expand Up @@ -228,7 +228,7 @@ var _ = Describe("stakers leave", Ordered, func() {
_, valaccountActive := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_0)
Expect(valaccountActive).To(BeFalse())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader got not slashed
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100 * i.KYVE))
Expand Down Expand Up @@ -344,7 +344,7 @@ var _ = Describe("stakers leave", Ordered, func() {
slashAmount := uint64(math.LegacyNewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64())

Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100*i.KYVE - slashAmount))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader did not receive the uploader reward
balanceUploader := s.GetBalanceFromAddress(i.STAKER_0)
Expand Down Expand Up @@ -444,7 +444,7 @@ var _ = Describe("stakers leave", Ordered, func() {
slashAmount := uint64(math.LegacyNewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64())

Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(100*i.KYVE - slashAmount))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader did not receive any rewards
balanceVoter := s.GetBalanceFromAddress(i.STAKER_1)
Expand Down Expand Up @@ -536,7 +536,7 @@ var _ = Describe("stakers leave", Ordered, func() {
// check if voter status

Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(100 * i.KYVE))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader did not receive any rewards
balanceVoter := s.GetBalanceFromAddress(i.STAKER_1)
Expand Down Expand Up @@ -631,7 +631,7 @@ var _ = Describe("stakers leave", Ordered, func() {

// check if voter not got slashed
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(100 * i.KYVE))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader did not receive any rewards
balanceVoter := s.GetBalanceFromAddress(i.STAKER_1)
Expand Down
2 changes: 1 addition & 1 deletion x/bundles/keeper/keeper_suite_valid_bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ var _ = Describe("valid bundles", Ordered, func() {
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.STAKER_2)).To(Equal(100*i.KYVE - slashAmountVoter))
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.CHARLIE)).To(Equal(300*i.KYVE - slashAmountDelegator))

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(800 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(800 * i.KYVE))

// check voter status
_, voterActive := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_2)
Expand Down
4 changes: 2 additions & 2 deletions x/bundles/keeper/keeper_suite_zero_delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ var _ = Describe("zero delegation", Ordered, func() {
slashAmountVoter := uint64(math.LegacyNewDec(int64(0 * i.KYVE)).Mul(fraction).TruncateInt64())
Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.STAKER_2)).To(Equal(0*i.KYVE - slashAmountVoter))

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200*i.KYVE - slashAmountVoter))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200*i.KYVE - slashAmountVoter))
})

It("Staker submit bundle proposal with zero delegation", func() {
Expand Down Expand Up @@ -619,7 +619,7 @@ var _ = Describe("zero delegation", Ordered, func() {
slashAmount := uint64(math.LegacyNewDec(int64(0 * i.KYVE)).Mul(fraction).TruncateInt64())

Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(0*i.KYVE - slashAmount))
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200*i.KYVE - slashAmount))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200*i.KYVE - slashAmount))

// check voter status
valaccountVoter, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_1)
Expand Down
33 changes: 9 additions & 24 deletions x/bundles/keeper/logic_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,17 @@ func (k Keeper) AssertPoolCanRun(ctx sdk.Context, poolId uint64) error {
return types.ErrEndKeyReached
}

// Get the total and the highest delegation of a single validator in the pool
totalDelegation, _ := k.stakerKeeper.GetTotalAndHighestDelegationOfPool(ctx, poolId)
if totalDelegation == 0 {
return types.ErrPoolHasZeroDelegation
// Error if max voting power is not achievable because there are not enough stakers
// in the pool
if k.stakerKeeper.IsVotingPowerTooHigh(ctx, poolId) {
return types.ErrVotingPowerTooHigh
}

// Error if min delegation is not reached
if totalDelegation < pool.MinDelegation {
if k.stakerKeeper.GetTotalStakeOfPool(ctx, poolId) < pool.MinDelegation {
return types.ErrMinDelegationNotReached
}

stakers := int64(len(k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, poolId)))
maxVotingPower := k.poolKeeper.GetMaxVotingPowerPerPool(ctx)

if maxVotingPower.IsZero() {
return nil
}

// Error if max voting power is not achievable because there are not enough stakers
// in the pool
if math.LegacyOneDec().Quo(maxVotingPower).GT(math.LegacyNewDec(stakers)) {
return types.ErrVotingPowerTooHigh
}

return nil
}

Expand Down Expand Up @@ -510,26 +497,24 @@ func (k Keeper) GetVoteDistribution(ctx sdk.Context, poolId uint64) (voteDistrib
return
}

effectiveStakes := k.stakerKeeper.GetEffectiveValidatorStakes(ctx, poolId)

// get voting power for valid
for _, voter := range bundleProposal.VotersValid {
voteDistribution.Valid += effectiveStakes[voter]
voteDistribution.Valid += k.stakerKeeper.GetValidatorPoolStake(ctx, voter, poolId)
}

// get voting power for invalid
for _, voter := range bundleProposal.VotersInvalid {
voteDistribution.Invalid += effectiveStakes[voter]
voteDistribution.Invalid += k.stakerKeeper.GetValidatorPoolStake(ctx, voter, poolId)
}

// get voting power for abstain
for _, voter := range bundleProposal.VotersAbstain {
voteDistribution.Abstain += effectiveStakes[voter]
voteDistribution.Abstain += k.stakerKeeper.GetValidatorPoolStake(ctx, voter, poolId)
}

// get total voting power
for _, staker := range k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, poolId) {
voteDistribution.Total += effectiveStakes[staker]
voteDistribution.Total += k.stakerKeeper.GetValidatorPoolStake(ctx, staker, poolId)
}

if voteDistribution.Total == 0 {
Expand Down
36 changes: 17 additions & 19 deletions x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,38 +281,36 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_1, 0)).To(Equal(20 * i.KYVE))
})

It("Next uploader gets not removed although pool having one node with more than 50% voting power", func() {
It("Next uploader gets removed due to pool having validators with too much voting power", func() {
// ARRANGE
s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{
Creator: i.VALADDRESS_0_A,
Staker: i.STAKER_0,
PoolId: 0,
})

s.RunTxSuccess(stakingTypes.NewMsgDelegate(
i.STAKER_0,
util.MustValaddressFromOperatorAddress(i.STAKER_0),
sdk.NewInt64Coin(globalTypes.Denom, int64(1*i.KYVE)),
))
params := s.App().PoolKeeper.GetParams(s.Ctx())
params.MaxVotingPowerPerPool = math.LegacyMustNewDecFromStr("0.2")
s.App().PoolKeeper.SetParams(s.Ctx(), params)

// ACT
s.CommitAfterSeconds(1)

// ASSERT
bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0)
Expect(bundleProposal.NextUploader).To(Equal("kyve1htgfatqevuvfzvl0sxp97ywteqhg5leha9emf4"))
Expect(bundleProposal.NextUploader).To(BeEmpty())
Expect(bundleProposal.StorageId).To(BeEmpty())

poolStakers := s.App().StakersKeeper.GetAllStakerAddressesOfPool(s.Ctx(), 0)
Expect(poolStakers).To(HaveLen(2))

_, found := s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_0)
Expect(found).To(BeTrue())
Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(101 * i.KYVE))
Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(BeZero())

_, found = s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_1)
Expect(found).To(BeTrue())
Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_1, 0)).To(Equal(100 * i.KYVE))
Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_1, 0)).To(BeZero())
})

It("Staker is next uploader of genesis bundle and upload interval and timeout does not pass", func() {
Expand Down Expand Up @@ -401,7 +399,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
_, found := s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_0)
Expect(found).To(BeTrue())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader not got slashed
expectedBalance := 100 * i.KYVE
Expand Down Expand Up @@ -578,7 +576,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Expect(expectedBalance).To(Equal(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)))

// pool delegations equals delegations of staker 0 & 1
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
})

It("Staker is next uploader of bundle proposal and upload timeout passes with the previous bundle not reaching quorum", func() {
Expand Down Expand Up @@ -641,7 +639,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Expect(found).To(BeTrue())

// pool delegations equals delegations of staker 0 & 1
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
})

It("Staker is next uploader of bundle proposal and upload timeout passes with the previous bundle being invalid", func() {
Expand Down Expand Up @@ -697,7 +695,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Vote: bundletypes.VOTE_TYPE_INVALID,
})

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(300 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(300 * i.KYVE))

// ACT
s.CommitAfterSeconds(s.App().BundlesKeeper.GetUploadTimeout(s.Ctx()))
Expand Down Expand Up @@ -739,7 +737,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Expect(expectedBalance).To(Equal(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.STAKER_2)))

// pool delegations equals delegations of staker 1 & 2
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
})

It("Staker with already max points is next uploader of bundle proposal and upload timeout passes", func() {
Expand Down Expand Up @@ -869,7 +867,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
Expect(expectedBalance).To(Equal(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.STAKER_2)))

// pool delegations equals delegations of staker 0 & 1
Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
})

It("A bundle proposal with no quorum does not reach the upload interval", func() {
Expand Down Expand Up @@ -1030,7 +1028,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
_, found = s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_2)
Expect(found).To(BeTrue())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader not got slashed
expectedBalance := 100 * i.KYVE
Expand Down Expand Up @@ -1118,7 +1116,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
_, found = s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_2)
Expect(found).To(BeTrue())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check if next uploader not got slashed
expectedBalance := 100 * i.KYVE
Expand Down Expand Up @@ -1201,7 +1199,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
_, found = s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_0)
Expect(found).To(BeTrue())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(200 * i.KYVE))

// check that uploader received upload slash
expectedBalance := 100*i.KYVE - uint64(s.App().StakersKeeper.GetUploadSlash(s.Ctx()).Mul(math.LegacyNewDec(int64(100*i.KYVE))).TruncateInt64())
Expand Down Expand Up @@ -1367,7 +1365,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() {
_, found = s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_2)
Expect(found).To(BeTrue())

Expect(s.App().StakersKeeper.GetDelegationOfPool(s.Ctx(), 1)).To(Equal(200 * i.KYVE))
Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 1)).To(Equal(200 * i.KYVE))

// check if next uploader not got slashed
slashAmountRatio := s.App().StakersKeeper.GetTimeoutSlash(s.Ctx())
Expand Down
Loading

0 comments on commit 36f8f16

Please sign in to comment.