Skip to content

Commit

Permalink
Merge pull request #547 from chengwenxi/develop
Browse files Browse the repository at this point in the history
R4R: fix sim mock and all sim test
  • Loading branch information
HaoyangLiu authored Nov 9, 2018
2 parents 104adb7 + 4978db8 commit d09519c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
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

0 comments on commit d09519c

Please sign in to comment.