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 1 commit
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
Prev Previous commit
Next Next commit
make TestDelegation pass with generated accounts
  • Loading branch information
jgimeno committed Feb 21, 2020
commit ee7ccc37040862ef897a8aa32405537670cab686
64 changes: 61 additions & 3 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,52 @@ 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

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
}

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()
addresses = append(addresses, TestAddr(buffer.String(), bech))
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)
}

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 @@ -107,6 +144,27 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd
return testAddrs
}

func TestAddr(addr string, bech string) sdk.AccAddress {
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
res, err := sdk.AccAddressFromHex(addr)
if err != nil {
panic(err)
}
bechexpected := res.String()
if bech != bechexpected {
panic("Bech encoding doesn't match reference")
}

bechres, err := sdk.AccAddressFromBech32(bech)
if err != nil {
panic(err)
}
if !bytes.Equal(bechres, res) {
panic("Bech decode and hex decode don't match")
}

return res
}

// 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
228 changes: 114 additions & 114 deletions x/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,120 +15,120 @@ import (
)

// tests GetDelegation, GetDelegatorDelegations, SetDelegation, RemoveDelegation, GetDelegatorDelegations
//func TestDelegation(t *testing.T) {
// _, app, ctx := getBaseSimappWithCustomKeeper()
//
// addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(10000))
//
// //construct the validators
// amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)}
// var validators [3]types.Validator
// for i, amt := range amts {
// validators[i] = types.NewValidator(sdk.ValAddress(addrs[i]), PKs[i], types.Description{})
// validators[i], _ = validators[i].AddTokensFromDel(amt)
// }
//
// validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], true)
// validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], true)
// validators[2] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[2], true)
//
// // first add a validators[0] to delegate too
// bond1to1 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[0]), sdk.NewDec(9))
//
// // check the empty keeper first
// _, found := app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
// require.False(t, found)
//
// // set and retrieve a record
// app.StakingKeeper.SetDelegation(ctx, bond1to1)
// resBond, found := app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
// require.True(t, found)
// require.True(t, bond1to1.Equal(resBond))
//
// // modify a records, save, and retrieve
// bond1to1.Shares = sdk.NewDec(99)
// app.StakingKeeper.SetDelegation(ctx, bond1to1)
// resBond, found = app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
// require.True(t, found)
// require.True(t, bond1to1.Equal(resBond))
//
// // add some more records
// bond1to2 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[1]), sdk.NewDec(9))
// bond1to3 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[2]), sdk.NewDec(9))
// bond2to1 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[0]), sdk.NewDec(9))
// bond2to2 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[1]), sdk.NewDec(9))
// bond2to3 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[2]), sdk.NewDec(9))
// app.StakingKeeper.SetDelegation(ctx, bond1to2)
// app.StakingKeeper.SetDelegation(ctx, bond1to3)
// app.StakingKeeper.SetDelegation(ctx, bond2to1)
// app.StakingKeeper.SetDelegation(ctx, bond2to2)
// app.StakingKeeper.SetDelegation(ctx, bond2to3)
//
// // test all bond retrieve capabilities
// resBonds := app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[0], 5)
// require.Equal(t, 3, len(resBonds))
// require.True(t, bond1to1.Equal(resBonds[0]))
// require.True(t, bond1to2.Equal(resBonds[1]))
// require.True(t, bond1to3.Equal(resBonds[2]))
// resBonds = app.StakingKeeper.GetAllDelegatorDelegations(ctx, addrs[0])
// require.Equal(t, 3, len(resBonds))
// resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[0], 2)
// require.Equal(t, 2, len(resBonds))
// resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[1], 5)
// require.Equal(t, 3, len(resBonds))
// require.True(t, bond2to1.Equal(resBonds[0]))
// require.True(t, bond2to2.Equal(resBonds[1]))
// require.True(t, bond2to3.Equal(resBonds[2]))
// allBonds := app.StakingKeeper.GetAllDelegations(ctx)
// require.Equal(t, 6, len(allBonds))
// require.True(t, bond1to1.Equal(allBonds[0]))
// require.True(t, bond1to2.Equal(allBonds[1]))
// require.True(t, bond1to3.Equal(allBonds[2]))
// require.True(t, bond2to1.Equal(allBonds[3]))
// require.True(t, bond2to2.Equal(allBonds[4]))
// require.True(t, bond2to3.Equal(allBonds[5]))
//
// resVals := app.StakingKeeper.GetDelegatorValidators(ctx, addrs[0], 3)
// require.Equal(t, 3, len(resVals))
// resVals = app.StakingKeeper.GetDelegatorValidators(ctx, addrs[1], 4)
// require.Equal(t, 3, len(resVals))
//
// for i := 0; i < 3; i++ {
// resVal, err := app.StakingKeeper.GetDelegatorValidator(ctx, addrs[0], sdk.ValAddress(addrs[i]))
// require.Nil(t, err)
// require.Equal(t, addrs[i], resVal.GetOperator())
//
// resVal, err = app.StakingKeeper.GetDelegatorValidator(ctx, addrs[1], sdk.ValAddress(addrs[i]))
// require.Nil(t, err)
// require.Equal(t, addrs[i], resVal.GetOperator())
//
// resDels := app.StakingKeeper.GetValidatorDelegations(ctx, sdk.ValAddress(addrs[i]))
// require.Len(t, resDels, 2)
// }
//
// // delete a record
// app.StakingKeeper.RemoveDelegation(ctx, bond2to3)
// _, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[2]))
// require.False(t, found)
// resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[1], 5)
// require.Equal(t, 2, len(resBonds))
// require.True(t, bond2to1.Equal(resBonds[0]))
// require.True(t, bond2to2.Equal(resBonds[1]))
//
// resBonds = app.StakingKeeper.GetAllDelegatorDelegations(ctx, addrs[1])
// require.Equal(t, 2, len(resBonds))
//
// // delete all the records from delegator 2
// app.StakingKeeper.RemoveDelegation(ctx, bond2to1)
// app.StakingKeeper.RemoveDelegation(ctx, bond2to2)
// _, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[0]))
// require.False(t, found)
// _, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[1]))
// require.False(t, found)
// resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrDels[1], 5)
// require.Equal(t, 0, len(resBonds))
//}
//
func TestDelegation(t *testing.T) {
_, app, ctx := getBaseSimappWithCustomKeeper()

addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000))

//construct the validators
amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)}
var validators [3]types.Validator
for i, amt := range amts {
validators[i] = types.NewValidator(sdk.ValAddress(addrs[i]), PKs[i], types.Description{})
validators[i], _ = validators[i].AddTokensFromDel(amt)
}

validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], true)
validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], true)
validators[2] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[2], true)

// first add a validators[0] to delegate too
bond1to1 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[0]), sdk.NewDec(9))

// check the empty keeper first
_, found := app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
require.False(t, found)

// set and retrieve a record
app.StakingKeeper.SetDelegation(ctx, bond1to1)
resBond, found := app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
require.True(t, found)
require.True(t, bond1to1.Equal(resBond))

// modify a records, save, and retrieve
bond1to1.Shares = sdk.NewDec(99)
app.StakingKeeper.SetDelegation(ctx, bond1to1)
resBond, found = app.StakingKeeper.GetDelegation(ctx, addrs[0], sdk.ValAddress(addrs[0]))
require.True(t, found)
require.True(t, bond1to1.Equal(resBond))

// add some more records
bond1to2 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[1]), sdk.NewDec(9))
bond1to3 := types.NewDelegation(addrs[0], sdk.ValAddress(addrs[2]), sdk.NewDec(9))
bond2to1 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[0]), sdk.NewDec(9))
bond2to2 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[1]), sdk.NewDec(9))
bond2to3 := types.NewDelegation(addrs[1], sdk.ValAddress(addrs[2]), sdk.NewDec(9))
app.StakingKeeper.SetDelegation(ctx, bond1to2)
app.StakingKeeper.SetDelegation(ctx, bond1to3)
app.StakingKeeper.SetDelegation(ctx, bond2to1)
app.StakingKeeper.SetDelegation(ctx, bond2to2)
app.StakingKeeper.SetDelegation(ctx, bond2to3)

// test all bond retrieve capabilities
resBonds := app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[0], 5)
require.Equal(t, 3, len(resBonds))
require.True(t, bond1to1.Equal(resBonds[0]))
require.True(t, bond1to2.Equal(resBonds[1]))
require.True(t, bond1to3.Equal(resBonds[2]))
resBonds = app.StakingKeeper.GetAllDelegatorDelegations(ctx, addrs[0])
require.Equal(t, 3, len(resBonds))
resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[0], 2)
require.Equal(t, 2, len(resBonds))
resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[1], 5)
require.Equal(t, 3, len(resBonds))
require.True(t, bond2to1.Equal(resBonds[0]))
require.True(t, bond2to2.Equal(resBonds[1]))
require.True(t, bond2to3.Equal(resBonds[2]))
allBonds := app.StakingKeeper.GetAllDelegations(ctx)
require.Equal(t, 6, len(allBonds))
require.True(t, bond1to1.Equal(allBonds[0]))
require.True(t, bond1to2.Equal(allBonds[1]))
require.True(t, bond1to3.Equal(allBonds[2]))
require.True(t, bond2to1.Equal(allBonds[3]))
require.True(t, bond2to2.Equal(allBonds[4]))
require.True(t, bond2to3.Equal(allBonds[5]))

resVals := app.StakingKeeper.GetDelegatorValidators(ctx, addrs[0], 3)
require.Equal(t, 3, len(resVals))
resVals = app.StakingKeeper.GetDelegatorValidators(ctx, addrs[1], 4)
require.Equal(t, 3, len(resVals))

for i := 0; i < 3; i++ {
resVal, err := app.StakingKeeper.GetDelegatorValidator(ctx, addrs[0], sdk.ValAddress(addrs[i]))
require.Nil(t, err)
require.Equal(t, sdk.ValAddress(addrs[i]), resVal.GetOperator())

resVal, err = app.StakingKeeper.GetDelegatorValidator(ctx, addrs[1], sdk.ValAddress(addrs[i]))
require.Nil(t, err)
require.Equal(t, sdk.ValAddress(addrs[i]), resVal.GetOperator())

resDels := app.StakingKeeper.GetValidatorDelegations(ctx, sdk.ValAddress(addrs[i]))
require.Len(t, resDels, 2)
}

// delete a record
app.StakingKeeper.RemoveDelegation(ctx, bond2to3)
_, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[2]))
require.False(t, found)
resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrs[1], 5)
require.Equal(t, 2, len(resBonds))
require.True(t, bond2to1.Equal(resBonds[0]))
require.True(t, bond2to2.Equal(resBonds[1]))

resBonds = app.StakingKeeper.GetAllDelegatorDelegations(ctx, addrs[1])
require.Equal(t, 2, len(resBonds))

// delete all the records from delegator 2
app.StakingKeeper.RemoveDelegation(ctx, bond2to1)
app.StakingKeeper.RemoveDelegation(ctx, bond2to2)
_, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[0]))
require.False(t, found)
_, found = app.StakingKeeper.GetDelegation(ctx, addrs[1], sdk.ValAddress(addrs[1]))
require.False(t, found)
resBonds = app.StakingKeeper.GetDelegatorDelegations(ctx, addrDels[1], 5)
require.Equal(t, 0, len(resBonds))
}

// tests Get/Set/Remove UnbondingDelegation
func TestUnbondingDelegation(t *testing.T) {
_, app, ctx := getBaseSimappWithCustomKeeper()
Expand Down