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

Migrate Keeper staking tests to use simapp #5683

Merged
merged 95 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
f912618
use simapp into keeper
jgimeno Feb 18, 2020
918949c
refactor TestHistoricalInfo to use simapp
jgimeno Feb 18, 2020
6025132
refactor historical info test
jgimeno Feb 18, 2020
c84c592
temporal commit on querier test, it passes
jgimeno Feb 18, 2020
7f8d0e6
commit end of day refactoring
jgimeno Feb 18, 2020
cdcbecb
rename and temp commit
jgimeno Feb 19, 2020
0d24d2b
fix test query validators
jgimeno Feb 20, 2020
29987a0
make TestQueryDelegations pass with simapp :D
jgimeno Feb 20, 2020
06c1448
rename function
jgimeno Feb 20, 2020
32a27af
make TestQueryRedelegations pass with simapp
jgimeno Feb 20, 2020
fdba5b5
finish keeper refactor for querier in staking using simapp
jgimeno Feb 20, 2020
9eaa5b0
refactor delegation test TestUnbondDelegation to use simapp
jgimeno Feb 21, 2020
27ff208
make all test pass temporary
jgimeno Feb 21, 2020
594e0a6
avoid usage of historicals
jgimeno Feb 21, 2020
e155b10
refactor creation of the simapp
jgimeno Feb 21, 2020
01aaf84
refactor creation of simapp
jgimeno Feb 21, 2020
8978576
comment before creating new way to generate accounts
jgimeno Feb 21, 2020
ee7ccc3
make TestDelegation pass with generated accounts
jgimeno Feb 21, 2020
e5b6780
refactor to use accounts
jgimeno Feb 21, 2020
8cf9219
refactor test unbondingdelegationsmax entries
jgimeno Feb 21, 2020
8378be2
refactor TestUndelegateSelfDelegationBelowMinSelfDelegation to use si…
jgimeno Feb 21, 2020
bbc2b33
update TestUndelegate from unbonding validator and fix bug
jgimeno Feb 24, 2020
6ce1218
refactor TestUndelegateFromUnbondedValidator to use simapp
jgimeno Feb 24, 2020
62dbd8b
TestUnbondingAllDelegationFromValidator to use simapp
jgimeno Feb 24, 2020
9a5aae9
refactor TestGetRedelegationsFromSrcValidator to use simapp
jgimeno Feb 24, 2020
e33844f
refactor TestRedelegation to use simapp
jgimeno Feb 24, 2020
27e2023
refactor TestRedelegateToSameValidator to use simapp
jgimeno Feb 24, 2020
ae44324
refacotr TestRedelegationMaxEntries to use simapp
jgimeno Feb 24, 2020
5bf1fa0
refactor delegation test
jgimeno Feb 24, 2020
a1fcb07
refactor TestRedelegateFromUnbondingValidator to use simapp
jgimeno Feb 24, 2020
17ee1f5
finish refactor delegation test
jgimeno Feb 24, 2020
3910ec2
refactor and remove unused code
jgimeno Feb 24, 2020
fe1012d
migrate revocation of old slash test
jgimeno Feb 24, 2020
a34575a
fix TestSlashUnbondingDelegation test to use simapp
jgimeno Feb 24, 2020
3ea53f5
refactor TestSlashRedelegation to use simapp
jgimeno Feb 24, 2020
7ee50ea
refactor TestSlashAtFutureHeight test
jgimeno Feb 24, 2020
b36cdac
test TestSlashAtNegativeHeight migrated to simapp
jgimeno Feb 24, 2020
a6767d3
migrated two tests from slash_test to use simapp
jgimeno Feb 25, 2020
15eaa12
refactor TestSlashWithRedelegation
jgimeno Feb 25, 2020
0cddd4f
end refactoring slash_test
jgimeno Feb 25, 2020
66abd1f
refactor first test validation to simapp
jgimeno Feb 25, 2020
25681ad
refacor TestUpdateValidatorByPowerIndex to use simapp
jgimeno Feb 25, 2020
385c5c5
refactor TestUpdateBondedValidatorsDecreaseCliff to simapp
jgimeno Feb 25, 2020
ed40111
refactor TestSlashToZeroPowerRemoved
jgimeno Feb 25, 2020
9fa658c
TestValidatorBasics
jgimeno Feb 25, 2020
460619f
refactro TestGetValidatorSortingUnmixed to simapp
jgimeno Feb 25, 2020
c7d68c5
refactor TestGetValidatorSortingMixed test to simap
jgimeno Feb 25, 2020
9955492
refctor TestGetValidatorsEdgeCases to use simapp
jgimeno Feb 25, 2020
96216c3
make test TestValidatorBondHeight pass
jgimeno Feb 25, 2020
b4ab8e5
refactor TestFullValidatorSetPowerChange test
jgimeno Feb 25, 2020
9ae5326
end refactoring validator_test
jgimeno Feb 25, 2020
8f779b1
clean code
jgimeno Feb 25, 2020
632e65f
move methods
jgimeno Feb 25, 2020
b931c49
rename
jgimeno Feb 25, 2020
a44bebc
rename commont test
jgimeno Feb 25, 2020
13f2138
Merge branch 'master' into jonathan/4875-staking-test-use-simapp
jgimeno Feb 25, 2020
194b97b
git remove unused vars
jgimeno Feb 25, 2020
660ffc8
refactor ordering functions
jgimeno Feb 25, 2020
399ea76
refactor old genesis_test to use simapp
jgimeno Feb 26, 2020
315572b
refactor TestValidatorByPowerIndex
jgimeno Feb 26, 2020
59ecf11
refactor TestDuplicatesMsgCreateValidator
jgimeno Feb 26, 2020
030f612
refactor TestInvalidPubKeyTypeMsgCreateValidator
jgimeno Feb 26, 2020
c314b93
temporary commit
jgimeno Feb 26, 2020
ee21805
refactor TestLegacyValidatorDelegations to use simapp
jgimeno Feb 26, 2020
3f319c2
refactor TestIncrementsMsgDelegate
jgimeno Feb 26, 2020
8ecd5b8
refactor next
jgimeno Feb 26, 2020
a07ed83
refactor TestEditValidatorIncreaseMinSelfDelegationBeyondCurrentBond
jgimeno Feb 26, 2020
46d62eb
refactor TestIncrementsMsgUnbond
jgimeno Feb 26, 2020
d251f64
refator TestMultipleMsgCreateValidator
jgimeno Feb 26, 2020
0e3b958
refactor TestMultipleMsgDelegate
jgimeno Feb 26, 2020
0fcf1e2
refactor TestJailValidator
jgimeno Feb 26, 2020
eb26b47
refactor TestUnbondingPeriod and TestValidatorQueue
jgimeno Feb 26, 2020
c58ec7f
refactor TestUnbondingFromUnbondingValidator and TestRedelegationPeriod
jgimeno Feb 26, 2020
4e16a08
refactor TestTransitiveRedelegation and TestMultipleRedelegationAtSam…
jgimeno Feb 26, 2020
9381500
refactor TestMultipleRedelegationAtUniqueTimes and TestMultipleUnbond…
jgimeno Feb 26, 2020
015fd43
refactor TestMultipleUnbondingDelegationAtUniqueTimes and TestUnbondi…
jgimeno Feb 26, 2020
bbbbc61
end refactor handler_test
jgimeno Feb 26, 2020
64c2971
remove test_common
jgimeno Feb 26, 2020
1d18f88
remove create test public keys
jgimeno Feb 26, 2020
c94a98f
fix based on PR comments
jgimeno Feb 26, 2020
1648edf
use prealloc array for ConvertAddrsToValAddrs
jgimeno Feb 26, 2020
14469cc
fix lint errors
jgimeno Feb 26, 2020
4de26fd
fix lint errors 2
jgimeno Feb 26, 2020
d279066
remove duplicated func
jgimeno Feb 27, 2020
ce46939
rename function names
jgimeno Feb 27, 2020
60293dd
Merge branch 'master' into jonathan/4875-staking-test-use-simapp
jgimeno Feb 27, 2020
2c32ff3
Merge branch 'master' into jonathan/4875-staking-test-use-simapp
jgimeno Feb 28, 2020
256e5fc
Update simapp/test_helpers.go
alexanderbez Feb 28, 2020
9aa2088
Update x/staking/keeper/keeper.go
alexanderbez Feb 28, 2020
03af49b
Update simapp/test_helpers.go
alexanderbez Feb 28, 2020
19546f2
Update simapp/test_helpers.go
alexanderbez Feb 28, 2020
2b688a0
Merge branch 'master' into jonathan/4875-staking-test-use-simapp
alexanderbez Feb 28, 2020
f8442bb
add last touches to the PR
jgimeno Feb 28, 2020
f090da2
edit text
jgimeno Feb 28, 2020
52c6e5e
Merge branch 'master' into jonathan/4875-staking-test-use-simapp
Feb 28, 2020
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
110 changes: 107 additions & 3 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package simapp

import (
"bytes"
"encoding/hex"
"fmt"
"strconv"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -77,15 +81,56 @@ func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount, balances ..
return app
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt
func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress {
type GenerateAccountStrategy func(int) []sdk.AccAddress

// random is a strategy used by addTestAddrs() in order to generated addresses in random order.
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
func random(accNum int) []sdk.AccAddress {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
testAddrs := make([]sdk.AccAddress, accNum)
for i := 0; i < accNum; i++ {
pk := ed25519.GenPrivKey().PubKey()
testAddrs[i] = sdk.AccAddress(pk.Address())
}

return testAddrs
}

// incremental is a strategy used by addTestAddrs() in order to generated addresses in ascending order.
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
func incremental(accNum int) []sdk.AccAddress {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
var addresses []sdk.AccAddress
var buffer bytes.Buffer

// start at 100 so we can make up to 999 test addresses with valid test addresses
for i := 100; i < (accNum + 100); i++ {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string

buffer.WriteString(numString) //adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHex(buffer.String())
bech := res.String()
addr, _ := TestAddr(buffer.String(), bech)

addresses = append(addresses, addr)
buffer.Reset()
}

return addresses
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, random)
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, incremental)
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
}

func addTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
testAddrs := strategy(accNum)

initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
totalSupply := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt.MulRaw(int64(len(testAddrs)))))
prevSupply := app.SupplyKeeper.GetSupply(ctx)
Expand All @@ -104,6 +149,38 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd
return testAddrs
}

//ConvertAddrsToValAddrs converts the provided addresses to
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress {
valAddrs := make([]sdk.ValAddress, len(addrs))

for i, addr := range addrs {
valAddrs[i] = sdk.ValAddress(addr)
}

return valAddrs
}

func TestAddr(addr string, bech string) (sdk.AccAddress, error) {
res, err := sdk.AccAddressFromHex(addr)
if err != nil {
return nil, err
}
bechexpected := res.String()
if bech != bechexpected {
return nil, fmt.Errorf("bech encoding doesn't match reference")
}

bechres, err := sdk.AccAddressFromBech32(bech)
if err != nil {
return nil, err
}
if !bytes.Equal(bechres, res) {
return nil, err
}

return res, nil
}

// CheckBalance checks the balance of an account.
func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins) {
ctxCheck := app.BaseApp.NewContext(true, abci.Header{})
Expand Down Expand Up @@ -187,3 +264,30 @@ func incrementAllSequenceNumbers(initSeqNums []uint64) {
initSeqNums[i]++
}
}

func CreateTestPubKeys(numPubKeys int) []crypto.PubKey {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
var publicKeys []crypto.PubKey
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
var buffer bytes.Buffer

//start at 10 to avoid changing 1 to 01, 2 to 02, etc
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
for i := 100; i < (numPubKeys + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") //base pubkey string
buffer.WriteString(numString) //adding on final two digits to make pubkeys unique
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String()))
buffer.Reset()
}

return publicKeys
}

func NewPubKeyFromHex(pk string) (res crypto.PubKey) {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
pkBytes, err := hex.DecodeString(pk)
if err != nil {
panic(err)
}
//res, err = crypto.PubKeyFromBytes(pkBytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

var pkEd ed25519.PubKeyEd25519
copy(pkEd[:], pkBytes)
return pkEd
}
76 changes: 67 additions & 9 deletions x/staking/common_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package staking_test

import (
"bytes"
"encoding/hex"
"strconv"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
cdc "github.com/cosmos/cosmos-sdk/simapp/codec"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -16,16 +25,10 @@ var (
addr1 = sdk.AccAddress(priv1.PubKey().Address())
priv2 = secp256k1.GenPrivKey()
addr2 = sdk.AccAddress(priv2.PubKey().Address())
addr3 = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
priv4 = secp256k1.GenPrivKey()
addr4 = sdk.AccAddress(priv4.PubKey().Address())
coins = sdk.Coins{sdk.NewCoin("foocoin", sdk.NewInt(10))}
fee = auth.NewStdFee(
100000,
sdk.Coins{sdk.NewCoin("foocoin", sdk.NewInt(0))},
)

commissionRates = staking.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())

PKs = createTestPubKeys(500)
)

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator {
Expand All @@ -38,3 +41,58 @@ func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk.
amount := sdk.NewCoin(sdk.DefaultBondDenom, amt)
return staking.NewMsgDelegate(delAddr, valAddr, amount)
}

// nolint: unparam
func createTestPubKeys(numPubKeys int) []crypto.PubKey {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
var publicKeys []crypto.PubKey
var buffer bytes.Buffer

//start at 10 to avoid changing 1 to 01, 2 to 02, etc
for i := 100; i < (numPubKeys + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") //base pubkey string
buffer.WriteString(numString) //adding on final two digits to make pubkeys unique
publicKeys = append(publicKeys, NewPubKey(buffer.String()))
buffer.Reset()
}
return publicKeys
}

func NewPubKey(pk string) (res crypto.PubKey) {
pkBytes, err := hex.DecodeString(pk)
if err != nil {
panic(err)
}
//res, err = crypto.PubKeyFromBytes(pkBytes)
var pkEd ed25519.PubKeyEd25519
copy(pkEd[:], pkBytes)
return pkEd
}

// getBaseSimappWithCustomKeeper Returns a simapp with custom StakingKeeper
// to avoid messing with the hooks.
func getBaseSimappWithCustomKeeper() (*codec.Codec, *simapp.SimApp, sdk.Context) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, abci.Header{})

appCodec := cdc.NewAppCodec(codec.New())

app.StakingKeeper = keeper.NewKeeper(
appCodec,
app.GetKey(staking.StoreKey),
app.BankKeeper,
app.SupplyKeeper,
app.GetSubspace(staking.ModuleName),
)
app.StakingKeeper.SetParams(ctx, types.DefaultParams())

return codec.New(), app, ctx
}

// generateAddresses generates numAddrs of normal AccAddrs and ValAddrs
func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int, accAmount int64) ([]sdk.AccAddress, []sdk.ValAddress) {
addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdk.NewInt(accAmount))
addrVals := simapp.ConvertAddrsToValAddrs(addrDels)

return addrDels, addrVals
}
77 changes: 48 additions & 29 deletions x/staking/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,64 +1,83 @@
package staking
package staking_test

import (
"fmt"
"testing"

jgimeno marked this conversation as resolved.
Show resolved Hide resolved
"github.com/tendermint/tendermint/crypto/ed25519"

"github.com/stretchr/testify/assert"

"github.com/stretchr/testify/require"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
keep "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/supply"
)

func bootstrapGenesisTest(t *testing.T, power int64, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress, []sdk.ValAddress) {
_, app, ctx := getBaseSimappWithCustomKeeper()

addrDels, addrVals := generateAddresses(app, ctx, numAddrs, 10000)

amt := sdk.TokensFromConsensusPower(power)
totalSupply := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), amt.MulRaw(int64(len(addrDels)))))

notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
err := app.BankKeeper.SetBalances(ctx, notBondedPool.GetAddress(), totalSupply)
require.NoError(t, err)
app.SupplyKeeper.SetModuleAccount(ctx, notBondedPool)

app.SupplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply))

return app, ctx, addrDels, addrVals
}

func TestInitGenesis(t *testing.T) {
ctx, accKeeper, bk, keeper, supplyKeeper := keep.CreateTestInput(t, false, 1000)
app, ctx, addrs, _ := bootstrapGenesisTest(t, 1000, 10)

valTokens := sdk.TokensFromConsensusPower(1)

params := keeper.GetParams(ctx)
validators := make([]Validator, 2)
var delegations []Delegation
params := app.StakingKeeper.GetParams(ctx)
validators := make([]types.Validator, 2)
var delegations []types.Delegation

pk0, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, keep.PKs[0])
pk0, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, PKs[0])
require.NoError(t, err)

pk1, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, keep.PKs[1])
pk1, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, PKs[1])
require.NoError(t, err)

// initialize the validators
validators[0].OperatorAddress = sdk.ValAddress(keep.Addrs[0])
validators[0].OperatorAddress = sdk.ValAddress(addrs[0])
validators[0].ConsensusPubkey = pk0
validators[0].Description = NewDescription("hoop", "", "", "", "")
validators[0].Description = types.NewDescription("hoop", "", "", "", "")
validators[0].Status = sdk.Bonded
validators[0].Tokens = valTokens
validators[0].DelegatorShares = valTokens.ToDec()
validators[1].OperatorAddress = sdk.ValAddress(keep.Addrs[1])
validators[1].OperatorAddress = sdk.ValAddress(addrs[1])
validators[1].ConsensusPubkey = pk1
validators[1].Description = NewDescription("bloop", "", "", "", "")
validators[1].Description = types.NewDescription("bloop", "", "", "", "")
validators[1].Status = sdk.Bonded
validators[1].Tokens = valTokens
validators[1].DelegatorShares = valTokens.ToDec()

genesisState := types.NewGenesisState(params, validators, delegations)
vals := InitGenesis(ctx, keeper, accKeeper, bk, supplyKeeper, genesisState)
vals := staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, genesisState)

actualGenesis := ExportGenesis(ctx, keeper)
actualGenesis := staking.ExportGenesis(ctx, app.StakingKeeper)
require.Equal(t, genesisState.Params, actualGenesis.Params)
require.Equal(t, genesisState.Delegations, actualGenesis.Delegations)
require.EqualValues(t, keeper.GetAllValidators(ctx), actualGenesis.Validators)
require.EqualValues(t, app.StakingKeeper.GetAllValidators(ctx), actualGenesis.Validators)

// now make sure the validators are bonded and intra-tx counters are correct
resVal, found := keeper.GetValidator(ctx, sdk.ValAddress(keep.Addrs[0]))
resVal, found := app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[0]))
require.True(t, found)
require.Equal(t, sdk.Bonded, resVal.Status)

resVal, found = keeper.GetValidator(ctx, sdk.ValAddress(keep.Addrs[1]))
resVal, found = app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[1]))
require.True(t, found)
require.Equal(t, sdk.Bonded, resVal.Status)

Expand All @@ -74,15 +93,15 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) {
size := 200
require.True(t, size > 100)

ctx, accKeeper, bk, keeper, supplyKeeper := keep.CreateTestInput(t, false, 1000)
app, ctx, addrs, _ := bootstrapGenesisTest(t, 1000, 200)

params := keeper.GetParams(ctx)
delegations := []Delegation{}
validators := make([]Validator, size)
params := app.StakingKeeper.GetParams(ctx)
delegations := []types.Delegation{}
validators := make([]types.Validator, size)

for i := range validators {
validators[i] = NewValidator(sdk.ValAddress(keep.Addrs[i]),
keep.PKs[i], NewDescription(fmt.Sprintf("#%d", i), "", "", "", ""))
validators[i] = types.NewValidator(sdk.ValAddress(addrs[i]),
PKs[i], types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", ""))

validators[i].Status = sdk.Bonded

Expand All @@ -95,7 +114,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) {
}

genesisState := types.NewGenesisState(params, validators, delegations)
vals := InitGenesis(ctx, keeper, accKeeper, bk, supplyKeeper, genesisState)
vals := staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, genesisState)

abcivals := make([]abci.ValidatorUpdate, 100)
for i, val := range validators[:100] {
Expand Down Expand Up @@ -140,9 +159,9 @@ func TestValidateGenesis(t *testing.T) {
genesisState := types.DefaultGenesisState()
tt.mutate(&genesisState)
if tt.wantErr {
assert.Error(t, ValidateGenesis(genesisState))
assert.Error(t, staking.ValidateGenesis(genesisState))
} else {
assert.NoError(t, ValidateGenesis(genesisState))
assert.NoError(t, staking.ValidateGenesis(genesisState))
}
})
}
Expand Down
Loading