Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds validator qgb checks tests #138

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0e9a2db
first pass on tests fixes
rach-id May 3, 2022
49fadc4
fixes the rest of unit tests
rach-id May 4, 2022
c3fe6aa
remove unnecessary comments
rach-id May 5, 2022
168a6fe
uses default eth address when starting sim network
rach-id May 5, 2022
af04769
cosmetics
rach-id May 5, 2022
bbf69d4
comments failing test
rach-id May 5, 2022
a910030
comments failing test
rach-id May 5, 2022
756f041
adds orchestrator/ethereum address checks for validators when creatin…
rach-id May 5, 2022
e70bbd8
uses correct error codes for eth/orch address errors
rach-id May 5, 2022
f53f9d6
uncomments test and fixes it from commit 434b308ce4dc968070c47952d948…
rach-id May 5, 2022
edf6b87
Merge branch 'fix_tests_after_qgb_changes' into adds_validator_qgb_ch…
rach-id May 5, 2022
0f372b9
updates tests to be able to set orch/eth address when creating valida…
rach-id May 5, 2022
8568eac
adds zero eth address check when creating/updating validator
rach-id May 6, 2022
b6fbf3a
attempts to fix duplicate eth address in sim network
rach-id May 6, 2022
8024e24
Merge branch 'adds_validator_qgb_checks' into adds_validator_qgb_chec…
rach-id May 6, 2022
52e0ed4
adds validator check tests
rach-id May 6, 2022
a10f734
Merge branch 'rachid/orchestrator-address' into adds_validator_qgb_ch…
rach-id May 6, 2022
3dbbe6c
revert squashed changes
rach-id May 6, 2022
57cdd6e
Merge branch 'adds_validator_qgb_checks' into adds_validator_qgb_chec…
rach-id May 6, 2022
a547c1b
uses unwrapped context for msg_server orch/eth validation
rach-id May 7, 2022
03e8b0c
increase DefaultGenTxGas to accomodate new qgb validator changes
rach-id May 9, 2022
fd79550
scaffolds an ethereum address from orchestrator address in staking si…
rach-id May 9, 2022
a799b09
fix eth address creation from orch address in operations
rach-id May 9, 2022
fa29549
increase DefaultGenTxGas
rach-id May 9, 2022
308853d
increase DefaultGenTxGas
rach-id May 9, 2022
5b0a66f
Merge branch 'adds_validator_qgb_checks' into adds_validator_qgb_chec…
rach-id May 9, 2022
e93aa8d
Merge branch 'rachid/orchestrator-address' into adds_validator_qgb_ch…
rach-id May 9, 2022
3c1de9c
remove unnecessary eth address
rach-id May 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions x/distribution/keeper/allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234))
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)
val := app.StakingKeeper.Validator(ctx, valAddrs[0])

// allocate tokens
Expand All @@ -48,16 +50,20 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234))
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// create second validator with 0% commission
randomEthAddress2, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), sdk.AccAddress(valConsPk2.Address()), *randomEthAddress2, true)

abciValA := abci.Validator{
Address: valConsPk1.Address(),
Expand Down Expand Up @@ -123,16 +129,22 @@ func TestAllocateTokensTruncation(t *testing.T) {
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 10% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// create second validator with 10% commission
randomEthAddress2, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), sdk.AccAddress(valConsPk2.Address()), *randomEthAddress2, true)

// create third validator with 10% commission
randomEthAddress3, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), sdk.AccAddress(valConsPk3.Address()), *randomEthAddress3, true)

abciValA := abci.Validator{
Address: valConsPk1.Address(),
Expand Down
36 changes: 26 additions & 10 deletions x/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ func TestCalculateRewardsBasic(t *testing.T) {
valAddrs := simapp.ConvertAddrsToValAddrs(addr)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator and start new block
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -78,7 +80,9 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valPower := int64(100)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -139,9 +143,11 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
valAddrs := simapp.ConvertAddrsToValAddrs(addr)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valPower := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -214,8 +220,10 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
valAddrs := simapp.ConvertAddrsToValAddrs(addr)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -284,9 +292,11 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
power := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valTokens := tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, power, true)
valTokens := tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, power, sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// assert correct initial balance
expTokens := balanceTokens.Sub(valTokens)
Expand Down Expand Up @@ -314,7 +324,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))

// withdraw rewards
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
_, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
require.Nil(t, err)

// historical count should still be 2 (added one record, cleared one)
Expand Down Expand Up @@ -348,9 +358,11 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valPower := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -416,9 +428,11 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
valAddrs := simapp.ConvertAddrsToValAddrs(addr)

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valPower := int64(100)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -498,8 +512,10 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))}

// create validator with 50% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
Expand Down Expand Up @@ -537,7 +553,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

// first delegator withdraws
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
_, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
require.NoError(t, err)

// second delegator withdraws
Expand Down
4 changes: 3 additions & 1 deletion x/distribution/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ func (suite *KeeperTestSuite) TestGRPCDelegationRewards() {

tstaking := teststaking.NewHelper(suite.T(), ctx, app.StakingKeeper)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
randomEthAddress, err := teststaking.RandomEthAddress()
suite.NoError(err)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

staking.EndBlocker(ctx, app.StakingKeeper)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
Expand Down
4 changes: 3 additions & 1 deletion x/distribution/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ func TestQueries(t *testing.T) {
// test delegation rewards query
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valOpAddr1, valConsPk1, sdk.NewInt(100), true)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.CreateValidator(valOpAddr1, valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

staking.EndBlocker(ctx, app.StakingKeeper)

Expand Down
8 changes: 6 additions & 2 deletions x/evidence/keeper/infraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() {
power := int64(100)
stakingParams := suite.app.StakingKeeper.GetParams(ctx)
operatorAddr, val := valAddresses[0], pubkeys[0]
randomEthAddress, err := teststaking.RandomEthAddress()
suite.NoError(err)
tstaking := teststaking.NewHelper(suite.T(), ctx, suite.app.StakingKeeper)

selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, sdk.AccAddress(val.Address()), *randomEthAddress, true)

// execute end-blocker and verify validator attributes
staking.EndBlocker(ctx, suite.app.StakingKeeper)
Expand Down Expand Up @@ -82,9 +84,11 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() {
power := int64(100)
stakingParams := suite.app.StakingKeeper.GetParams(ctx)
operatorAddr, val := valAddresses[0], pubkeys[0]
randomEthAddress, err := teststaking.RandomEthAddress()
suite.NoError(err)
tstaking := teststaking.NewHelper(suite.T(), ctx, suite.app.StakingKeeper)

amt := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)
amt := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, sdk.AccAddress(val.Address()), *randomEthAddress, true)

// execute end-blocker and verify validator attributes
staking.EndBlocker(ctx, suite.app.StakingKeeper)
Expand Down
4 changes: 3 additions & 1 deletion x/slashing/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func TestBeginBlocker(t *testing.T) {

// bond the validator
power := int64(100)
amt := tstaking.CreateValidatorWithValPower(addr, pk, power, true)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
amt := tstaking.CreateValidatorWithValPower(addr, pk, power, sdk.AccAddress(pk.Address()), *randomEthAddress, true)
staking.EndBlocker(ctx, app.StakingKeeper)
require.Equal(
t, app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr)),
Expand Down
19 changes: 14 additions & 5 deletions x/slashing/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ func TestCannotUnjailUnlessJailed(t *testing.T) {
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
slh := slashing.NewHandler(app.SlashingKeeper)
addr, val := sdk.ValAddress(pks[0].Address()), pks[0]
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)

amt := tstaking.CreateValidatorWithValPower(addr, val, 100, true)
amt := tstaking.CreateValidatorWithValPower(addr, val, 100, sdk.AccAddress(val.Address()), *randomEthAddress, true)
staking.EndBlocker(ctx, app.StakingKeeper)
require.Equal(
t, app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr)),
Expand All @@ -58,7 +60,10 @@ func TestCannotUnjailUnlessMeetMinSelfDelegation(t *testing.T) {
slh := slashing.NewHandler(app.SlashingKeeper)
addr, val := sdk.ValAddress(pks[0].Address()), pks[0]
amt := app.StakingKeeper.TokensFromConsensusPower(ctx, 100)
msg := tstaking.CreateValidatorMsg(addr, val, amt)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)

msg := tstaking.CreateValidatorMsg(addr, val, amt, sdk.AccAddress(val.Address()), *randomEthAddress)
msg.MinSelfDelegation = amt
tstaking.Handle(msg, true)

Expand Down Expand Up @@ -91,8 +96,10 @@ func TestJailedValidatorDelegations(t *testing.T) {
stakingParams := app.StakingKeeper.GetParams(ctx)
app.StakingKeeper.SetParams(ctx, stakingParams)
valAddr, consAddr := sdk.ValAddress(pks[1].Address()), sdk.ConsAddress(pks[0].Address())
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)

amt := tstaking.CreateValidatorWithValPower(valAddr, pks[1], 10, true)
amt := tstaking.CreateValidatorWithValPower(valAddr, pks[1], 10, sdk.AccAddress(pks[1].Address()), *randomEthAddress, true)
staking.EndBlocker(ctx, app.StakingKeeper)

// set dummy signing info
Expand All @@ -106,7 +113,7 @@ func TestJailedValidatorDelegations(t *testing.T) {
// unbond validator total self-delegations (which should jail the validator)
valAcc := sdk.AccAddress(valAddr)
tstaking.Undelegate(valAcc, valAddr, amt, true)
_, err := app.StakingKeeper.CompleteUnbonding(ctx, sdk.AccAddress(valAddr), valAddr)
_, err = app.StakingKeeper.CompleteUnbonding(ctx, sdk.AccAddress(valAddr), valAddr)
require.Nil(t, err, "expected complete unbonding validator to be ok, got: %v", err)

// verify validator still exists and is jailed
Expand Down Expand Up @@ -150,10 +157,12 @@ func TestHandleAbsentValidator(t *testing.T) {

power := int64(100)
addr, val := sdk.ValAddress(pks[0].Address()), pks[0]
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
slh := slashing.NewHandler(app.SlashingKeeper)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

amt := tstaking.CreateValidatorWithValPower(addr, val, power, true)
amt := tstaking.CreateValidatorWithValPower(addr, val, power, sdk.AccAddress(val.Address()), *randomEthAddress, true)
staking.EndBlocker(ctx, app.StakingKeeper)

require.Equal(
Expand Down
24 changes: 18 additions & 6 deletions x/slashing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func TestUnJailNotBonded(t *testing.T) {
// create max (5) validators all with the same power
for i := uint32(0); i < p.MaxValidators; i++ {
addr, val := valAddrs[i], pks[i]
tstaking.CreateValidatorWithValPower(addr, val, 100, true)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.CreateValidatorWithValPower(addr, val, 100, sdk.AccAddress(val.Address()), *randomEthAddress, true)
}

staking.EndBlocker(ctx, app.StakingKeeper)
Expand All @@ -40,7 +42,9 @@ func TestUnJailNotBonded(t *testing.T) {
// create a 6th validator with less power than the cliff validator (won't be bonded)
addr, val := valAddrs[5], pks[5]
amt := app.StakingKeeper.TokensFromConsensusPower(ctx, 50)
msg := tstaking.CreateValidatorMsg(addr, val, amt)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
msg := tstaking.CreateValidatorMsg(addr, val, amt, sdk.AccAddress(val.Address()), *randomEthAddress)
msg.MinSelfDelegation = amt
tstaking.Handle(msg, true)

Expand Down Expand Up @@ -89,9 +93,11 @@ func TestHandleNewValidator(t *testing.T) {
addr, val := valAddrs[0], pks[0]
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
ctx = ctx.WithBlockHeight(app.SlashingKeeper.SignedBlocksWindow(ctx) + 1)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)

// Validator created
amt := tstaking.CreateValidatorWithValPower(addr, val, 100, true)
amt := tstaking.CreateValidatorWithValPower(addr, val, 100, sdk.AccAddress(val.Address()), *randomEthAddress, true)

staking.EndBlocker(ctx, app.StakingKeeper)
require.Equal(
Expand Down Expand Up @@ -132,9 +138,11 @@ func TestHandleAlreadyJailed(t *testing.T) {
pks := simapp.CreateTestPubKeys(1)
addr, val := valAddrs[0], pks[0]
power := int64(100)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

amt := tstaking.CreateValidatorWithValPower(addr, val, power, true)
amt := tstaking.CreateValidatorWithValPower(addr, val, power, sdk.AccAddress(val.Address()), *randomEthAddress, true)

staking.EndBlocker(ctx, app.StakingKeeper)

Expand Down Expand Up @@ -194,8 +202,10 @@ func TestValidatorDippingInAndOut(t *testing.T) {
consAddr := sdk.ConsAddress(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
valAddr := sdk.ValAddress(addr)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)

tstaking.CreateValidatorWithValPower(valAddr, val, power, true)
tstaking.CreateValidatorWithValPower(valAddr, val, power, sdk.AccAddress(val.Address()), *randomEthAddress, true)
staking.EndBlocker(ctx, app.StakingKeeper)

// 100 first blocks OK
Expand All @@ -206,7 +216,9 @@ func TestValidatorDippingInAndOut(t *testing.T) {
}

// kick first validator out of validator set
tstaking.CreateValidatorWithValPower(sdk.ValAddress(pks[1].Address()), pks[1], 101, true)
randomEthAddress2, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.CreateValidatorWithValPower(sdk.ValAddress(pks[1].Address()), pks[1], 101, sdk.AccAddress(pks[1].Address()), *randomEthAddress2, true)
validatorUpdates := staking.EndBlocker(ctx, app.StakingKeeper)
require.Equal(t, 2, len(validatorUpdates))
tstaking.CheckValidator(valAddr, stakingtypes.Unbonding, false)
Expand Down
Loading