Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Oct 10, 2023
1 parent 51b18cc commit 1b48b90
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions x/oracle/keeper/update_exchange_rates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,33 @@ func TestOracleTally(t *testing.T) {
maxSpread = standardDeviation
}

expectedValidatorClaimMap := make(types.ValidatorPerformances)
expectedValidatorPerformances := make(types.ValidatorPerformances)
for _, valAddr := range valAddrs {
expectedValidatorClaimMap[valAddr.String()] = types.NewValidatorPerformance(
expectedValidatorPerformances[valAddr.String()] = types.NewValidatorPerformance(
stakingKeeper.Validator(fixture.Ctx, valAddr).GetConsensusPower(sdk.DefaultPowerReduction),
valAddr,
)
}

for _, vote := range ballot {
key := vote.Voter.String()
claim := expectedValidatorClaimMap[key]
validatorPerformance := expectedValidatorPerformances[key]
if vote.ExchangeRate.GTE(weightedMedian.Sub(maxSpread)) &&
vote.ExchangeRate.LTE(weightedMedian.Add(maxSpread)) {
claim.RewardWeight += vote.Power
claim.WinCount++
validatorPerformance.RewardWeight += vote.Power
validatorPerformance.WinCount++
} else if !vote.ExchangeRate.IsPositive() {
claim.AbstainCount++
validatorPerformance.AbstainCount++
} else {
claim.MissCount++
validatorPerformance.MissCount++
}
expectedValidatorClaimMap[key] = claim
expectedValidatorPerformances[key] = validatorPerformance
}

tallyMedian := Tally(
ballot, fixture.OracleKeeper.RewardBand(fixture.Ctx), validatorPerformances)

assert.Equal(t, expectedValidatorClaimMap, validatorPerformances)
assert.Equal(t, expectedValidatorPerformances, validatorPerformances)
assert.Equal(t, tallyMedian.MulInt64(100).TruncateInt(), weightedMedian.MulInt64(100).TruncateInt())
assert.NotEqualValues(t, 0, validatorPerformances.TotalRewardWeight(), validatorPerformances.String())
}
Expand Down

0 comments on commit 1b48b90

Please sign in to comment.