Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Dec 21, 2024
1 parent d1aaaae commit 060bb34
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions x/symbiotic/keeper/network_state_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ package keeper_test
import (
"time"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
appparams "github.com/ojo-network/ojo/app/params"
"github.com/ojo-network/ojo/x/symbiotic/types"
)

const (
ojoMiddlewareAddress = "0x127E303D6604C48f3bA0010EbEa57e09324A4dF6"
secret = "fixed_seed_value"
)

func (s *IntegrationTestSuite) TestSymbioticUpdateValidatorsPower() {
Expand All @@ -16,6 +24,26 @@ func (s *IntegrationTestSuite) TestSymbioticUpdateValidatorsPower() {
WithBlockHeight(10).
WithBlockTime(time.Now())

sh := stakingtestutil.NewHelper(s.T(), ctx, app.StakingKeeper)
sh.Denom = appparams.BondDenom
privKey := secp256k1.GenPrivKeyFromSecret([]byte(secret))
pubKey := privKey.PubKey()

initTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)
initCoins := sdk.NewCoins(sdk.NewCoin(appparams.BondDenom, initTokens))

s.app.BankKeeper.MintCoins(s.ctx, minttypes.ModuleName, initCoins)
s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, minttypes.ModuleName, sdk.AccAddress(pubKey.Address()), initCoins)

sh.CreateValidatorWithValPower(
sdk.ValAddress(pubKey.Address()),
pubKey,
1000,
true,
)
val, err := app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(pubKey.Address()))
s.Require().Equal(val.GetTokens(), math.NewInt(1000000000))

params := app.SymbioticKeeper.GetParams(ctx)
params.MiddlewareAddress = ojoMiddlewareAddress
app.SymbioticKeeper.SetParams(ctx, params)
Expand All @@ -28,10 +56,14 @@ func (s *IntegrationTestSuite) TestSymbioticUpdateValidatorsPower() {
Height: ctx.BlockHeight(),
}

s.app.SymbioticKeeper.SetCachedBlockHash(ctx, cachedBlockHash)
app.SymbioticKeeper.SetCachedBlockHash(ctx, cachedBlockHash)

err = app.SymbioticKeeper.SymbioticUpdateValidatorsPower(ctx)
s.Require().NoError(err)

err = s.app.SymbioticKeeper.SymbioticUpdateValidatorsPower(ctx)
val, err = app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(pubKey.Address()))
s.Require().NoError(err)
s.Require().Equal(val.GetTokens(), math.NewInt(0))
}

func (s *IntegrationTestSuite) TestFinalizedBlockHash() {
Expand Down

0 comments on commit 060bb34

Please sign in to comment.