Skip to content

Commit

Permalink
migrate TestTallyNoOneVotes to use simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
jgimeno committed Mar 2, 2020
1 parent 80bfd0d commit 8c0d32c
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 415 deletions.
42 changes: 42 additions & 0 deletions x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package keeper_test
import (
"bytes"

"github.com/cosmos/cosmos-sdk/simapp/codec"

"github.com/cosmos/cosmos-sdk/simapp"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking"

"github.com/cosmos/cosmos-sdk/x/gov/types"
)

Expand All @@ -15,3 +22,38 @@ func ProposalEqual(proposalA types.Proposal, proposalB types.Proposal) bool {
return bytes.Equal(types.ModuleCdc.MustMarshalBinaryBare(proposalA),
types.ModuleCdc.MustMarshalBinaryBare(proposalB))
}

func createValidators(ctx sdk.Context, app *simapp.SimApp, powers []int64) {
addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
pks := simapp.CreateTestPubKeys(3)

appCodec := codec.NewAppCodec(app.Codec())
app.StakingKeeper = staking.NewKeeper(
appCodec,
app.GetKey(staking.StoreKey),
app.BankKeeper,
app.SupplyKeeper,
app.GetSubspace(staking.ModuleName),
)

val1 := staking.NewValidator(valAddrs[0], pks[0], staking.Description{})
val2 := staking.NewValidator(valAddrs[1], pks[1], staking.Description{})
val3 := staking.NewValidator(valAddrs[2], pks[2], staking.Description{})

app.StakingKeeper.SetValidator(ctx, val1)
app.StakingKeeper.SetValidator(ctx, val2)
app.StakingKeeper.SetValidator(ctx, val3)
app.StakingKeeper.SetValidatorByConsAddr(ctx, val1)
app.StakingKeeper.SetValidatorByConsAddr(ctx, val2)
app.StakingKeeper.SetValidatorByConsAddr(ctx, val3)
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val1)
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2)
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val3)

_, _ = app.StakingKeeper.Delegate(ctx, addrs[0], sdk.TokensFromConsensusPower(powers[0]), sdk.Unbonded, val1, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[1], sdk.TokensFromConsensusPower(powers[1]), sdk.Unbonded, val2, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[2], sdk.TokensFromConsensusPower(powers[2]), sdk.Unbonded, val3, true)

_ = staking.EndBlocker(ctx, app.StakingKeeper)
}
1 change: 0 additions & 1 deletion x/gov/keeper/old_querier_test.go

This file was deleted.

Loading

0 comments on commit 8c0d32c

Please sign in to comment.