mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-14 03:55:19 +00:00
73bc32a183
* Update incentive test to use beginblocker instead manual accumulation * Update integration test suite * Add base integration test, wip staking reward calculation * Get actual staking reward amounts from BeginBlocker events, calculate expected indexes * Simplify event parsing * Add initial earn accum test with real keepers * Add the rest of the accum integration tests with real keepers * Check if delegation rewards are zero before transferring * Update staking integration test to use updated methods
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/kava-labs/kava/x/incentive/keeper"
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
|
)
|
|
|
|
// TestKeeper is a test wrapper for the keeper which contains useful methods for testing
|
|
type TestKeeper struct {
|
|
keeper.Keeper
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalBorrowIndexes(ctx sdk.Context, indexes types.MultiRewardIndexes) {
|
|
for _, i := range indexes {
|
|
keeper.SetHardBorrowRewardIndexes(ctx, i.CollateralType, i.RewardIndexes)
|
|
}
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalSupplyIndexes(ctx sdk.Context, indexes types.MultiRewardIndexes) {
|
|
for _, i := range indexes {
|
|
keeper.SetHardSupplyRewardIndexes(ctx, i.CollateralType, i.RewardIndexes)
|
|
}
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalDelegatorIndexes(ctx sdk.Context, multiRewardIndexes types.MultiRewardIndexes) {
|
|
// Hardcoded to use bond denom
|
|
multiRewardIndex, _ := multiRewardIndexes.GetRewardIndex(types.BondDenom)
|
|
keeper.SetDelegatorRewardIndexes(ctx, types.BondDenom, multiRewardIndex.RewardIndexes)
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalSwapIndexes(ctx sdk.Context, indexes types.MultiRewardIndexes) {
|
|
for _, i := range indexes {
|
|
keeper.SetSwapRewardIndexes(ctx, i.CollateralType, i.RewardIndexes)
|
|
}
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalSavingsIndexes(ctx sdk.Context, indexes types.MultiRewardIndexes) {
|
|
for _, i := range indexes {
|
|
keeper.SetSavingsRewardIndexes(ctx, i.CollateralType, i.RewardIndexes)
|
|
}
|
|
}
|
|
|
|
func (keeper TestKeeper) storeGlobalEarnIndexes(ctx sdk.Context, indexes types.MultiRewardIndexes) {
|
|
for _, i := range indexes {
|
|
keeper.SetEarnRewardIndexes(ctx, i.CollateralType, i.RewardIndexes)
|
|
}
|
|
}
|