Skip to content

Commit

Permalink
test(x/oracle): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pyncz committed Nov 19, 2024
1 parent 737fec8 commit afbe7c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions x/oracle/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func TestOracleTallyTiming(t *testing.T) {
_, err = keepers.OracleKeeper.ExchangeRates.Get(ctx, asset.Registry.Pair(denoms.BTC, denoms.USD))
require.Error(t, err)

ctx = ctx.WithBlockHeight(int64(params.VotePeriod - 1))

ctx = ctx.WithBlockHeight(int64(params.VotePeriod))
oracle.EndBlocker(ctx, keepers.OracleKeeper)

_, err = keepers.OracleKeeper.ExchangeRates.Get(ctx, asset.Registry.Pair(denoms.BTC, denoms.USD))
require.NoError(t, err)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestOraclePriceExpiration(t *testing.T) {
keepers.OracleKeeper.Params.Set(ctx, params)

// Wait for prices to set
ctx = ctx.WithBlockHeight(int64(params.VotePeriod - 1))
ctx = ctx.WithBlockHeight(int64(params.VotePeriod))
oracle.EndBlocker(ctx, keepers.OracleKeeper)

// Check if both prices are set
Expand All @@ -120,19 +120,20 @@ func TestOraclePriceExpiration(t *testing.T) {
require.NoError(t, err)

// Set prices for pair 1
voteHeight := int64(params.VotePeriod+params.ExpirationBlocks) - 1
for _, val := range chain.GetCurrentValSet().Validators {
MakeAggregatePrevoteAndVote(t, ctx, msgServer, 19, types.ExchangeRateTuples{
MakeAggregatePrevoteAndVote(t, ctx, msgServer, voteHeight, types.ExchangeRateTuples{
{Pair: pair1, ExchangeRate: math.LegacyNewDec(2)},
}, val)
}

// Set price
ctx = ctx.WithBlockHeight(19)
ctx = ctx.WithBlockHeight(voteHeight)
oracle.EndBlocker(ctx, keepers.OracleKeeper)

// Set the block height to 1 block after the expiration
// Set the block height to the expiration height
// End blocker should delete the price of pair2
ctx = ctx.WithBlockHeight(int64(params.ExpirationBlocks+params.VotePeriod) + 1)
ctx = ctx.WithBlockHeight(int64(params.ExpirationBlocks + params.VotePeriod))
oracle.EndBlocker(ctx, keepers.OracleKeeper)

_, err = keepers.OracleKeeper.ExchangeRates.Get(ctx, pair1)
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/ballot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,5 @@ func TestZeroBallotPower(t *testing.T) {
types.NewExchangeRateVote(math.LegacyNewDec(6), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[2], 0),
}

assert.NoError(t, keeper.IsPassingVoteThreshold(btcVotess, math.ZeroInt(), 0))
assert.Error(t, keeper.IsPassingVoteThreshold(btcVotess, math.ZeroInt(), 0))
}

0 comments on commit afbe7c9

Please sign in to comment.