-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c06f61e
commit b5ee6db
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |