Skip to content

Commit

Permalink
chore: add abci test
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta-elys committed Sep 19, 2023
1 parent c06f61e commit b5ee6db
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions x/incentive/keeper/abci_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package keeper_test

import (
"testing"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
simapp "github.com/elys-network/elys/app"
ctypes "github.com/elys-network/elys/x/commitment/types"
ptypes "github.com/elys-network/elys/x/parameter/types"
"github.com/stretchr/testify/require"
)

func TestABCI_EndBlocker(t *testing.T) {
app, genAccount, _ := simapp.InitElysTestAppWithGenAccount()
ctx := app.BaseApp.NewContext(initChain, tmproto.Header{})

ik := app.IncentiveKeeper

var committed []sdk.Coins
var uncommitted []sdk.Coins

// Prepare uncommitted tokens
uedenToken := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)))
uedenBToken := sdk.NewCoins(sdk.NewCoin(ptypes.EdenB, sdk.NewInt(2000)))
uncommitted = append(uncommitted, uedenToken)
uncommitted = append(uncommitted, uedenBToken)

// Eden
err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, uedenToken)
require.NoError(t, err)
err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, genAccount, uedenToken)
require.NoError(t, err)

// EdenB
err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, uedenBToken)
require.NoError(t, err)
err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, genAccount, uedenBToken)
require.NoError(t, err)

// Add testing commitment
simapp.AddTestCommitment(app, ctx, genAccount, committed, uncommitted)
// Update Elys staked amount
ik.EndBlocker(ctx)

// Get elys staked
elysStaked, found := ik.GetElysStaked(ctx, genAccount.String())
require.Equal(t, found, true)
require.Equal(t, elysStaked.Amount, sdk.DefaultPowerReduction)
}

0 comments on commit b5ee6db

Please sign in to comment.