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

R4R: fix sim mock and all sim test #547

Merged
merged 2 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 1 addition & 19 deletions simulation/gov/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/irisnet/irishub/iparam"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/simulation/mock"
"github.com/irisnet/irishub/simulation/mock/simulation"
)
Expand All @@ -29,7 +26,6 @@ func TestGovWithRandomMessages(t *testing.T) {
stakeKey := mapp.KeyStake
stakeTKey := mapp.TkeyStake
paramKey := mapp.KeyParams
paramTKey := mapp.TkeyParams
govKey := sdk.NewKVStoreKey("gov")

paramKeeper := mapp.ParamsKeeper
Expand All @@ -45,28 +41,14 @@ func TestGovWithRandomMessages(t *testing.T) {
bankKeeper, stakeKeeper,
mapp.RegisterCodespace(gov.DefaultCodespace),
)
iparam.SetParamReadWriter(mapp.ParamsKeeper.Subspace(iparam.GovParamspace).WithTypeTable(
params.NewTypeTable(
govparams.DepositProcedureParameter.GetStoreKey(), govparams.DepositProcedure{},
govparams.VotingProcedureParameter.GetStoreKey(), govparams.VotingProcedure{},
govparams.TallyingProcedureParameter.GetStoreKey(), govparams.TallyingProcedure{},
)),
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter)

iparam.RegisterGovParamMapping(
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter)

mapp.Router().AddRoute("gov", []*sdk.KVStoreKey{govKey, mapp.KeyAccount, stakeKey, paramKey}, gov.NewHandler(govKeeper))
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
gov.EndBlocker(ctx, govKeeper)
return abci.ResponseEndBlock{}
})

err := mapp.CompleteSetup(stakeKey, stakeTKey, paramKey, paramTKey, govKey)
err := mapp.CompleteSetup(govKey)
if err != nil {
panic(err)
}
Expand Down
6 changes: 6 additions & 0 deletions simulation/mock/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type App struct {
TkeyStake *sdk.TransientStoreKey
KeyParams *sdk.KVStoreKey
TkeyParams *sdk.TransientStoreKey
KeyUpgrade *sdk.KVStoreKey

// TODO: Abstract this out from not needing to be auth specifically
AccountKeeper auth.AccountKeeper
Expand Down Expand Up @@ -85,6 +86,7 @@ func NewApp() *App {
TkeyStake: sdk.NewTransientStoreKey("transient_stake"),
KeyParams: sdk.NewKVStoreKey("params"),
TkeyParams: sdk.NewTransientStoreKey("transient_params"),
KeyUpgrade: sdk.NewKVStoreKey("upgrade"),
TotalCoinsSupply: sdk.Coins{},
}

Expand Down Expand Up @@ -137,7 +139,11 @@ func NewApp() *App {
func (app *App) CompleteSetup(newKeys ...sdk.StoreKey) error {
newKeys = append(newKeys, app.KeyMain)
newKeys = append(newKeys, app.KeyAccount)
newKeys = append(newKeys, app.KeyParams)
newKeys = append(newKeys, app.KeyStake)
newKeys = append(newKeys, app.KeyFeeCollection)
newKeys = append(newKeys, app.TkeyParams)
newKeys = append(newKeys, app.TkeyStake)

for _, key := range newKeys {
switch key.(type) {
Expand Down
2 changes: 1 addition & 1 deletion simulation/stake/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestStakeWithRandomMessages(t *testing.T) {
}
})

err := mapp.CompleteSetup(stakeKey, stakeTKey, paramsKey, paramsTKey, distrKey)
err := mapp.CompleteSetup(distrKey)
if err != nil {
panic(err)
}
Expand Down