Skip to content

Commit

Permalink
add calibrate delegation test
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-stride committed Oct 11, 2023
1 parent 1b1095b commit 856bf8c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions x/stakeibc/keeper/icqcallbacks_delegator_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,24 @@ func (s *KeeperTestSuite) TestDelegatorSharesCallback_PrecisionError() {
expectedValDelegation := tc.hostZone.Validators[tc.valIndexQueried].Delegation.Add(precisionErrorTokens)
s.Require().Equal(expectedValDelegation.Int64(), validator.Delegation.Int64(), "validator delegation amount")
}

func (s *KeeperTestSuite) TestCalibrateDelegationCallback_Successful() {
tc := s.SetupDelegatorSharesICQCallback()

// Callback
err := keeper.CalibrateDelegationCallback(s.App.StakeibcKeeper, s.Ctx, tc.validArgs.callbackArgs, tc.validArgs.query)
s.Require().NoError(err, "calibrate delegation callback error")

// Confirm the staked balance was decreased on the host
hostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, HostChainId)
s.Require().True(found, "host zone found")
s.Require().Equal(tc.expectedSlashAmount.Int64(), tc.hostZone.TotalDelegations.Sub(hostZone.TotalDelegations).Int64(), "staked bal slash")

// Confirm the validator's weight and delegation amount were not reduced
validator := hostZone.Validators[tc.valIndexQueried]
s.Require().NotEqual(tc.expectedWeight, validator.Weight, "validator weight")
s.Require().Equal(tc.expectedDelegationAmount.Int64(), validator.Delegation.Int64(), "validator delegation amount")

// Confirm the validator query is still in progress (calibration callback does not set it false)
s.Require().True(validator.SlashQueryInProgress, "slash query in progress")
}

0 comments on commit 856bf8c

Please sign in to comment.