@@ -45,10 +45,13 @@ func SimulateSubmittingVotingAndSlashingForProposal(k gov.Keeper, sk stake.Keepe
4545 })
4646 statePercentageArray := []float64 {1 , .9 , .75 , .4 , .15 , 0 }
4747 curNumVotesState := 1
48- return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , log string , event func (string )) (action string , fOps []simulation.FutureOperation , err sdk. Error ) {
48+ return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , event func (string )) (action string , fOps []simulation.FutureOperation , err error ) {
4949 // 1) submit proposal now
5050 sender := simulation .RandomKey (r , keys )
51- msg := simulationCreateMsgSubmitProposal (tb , r , sender , log )
51+ msg , err := simulationCreateMsgSubmitProposal (tb , r , sender )
52+ if err != nil {
53+ return "" , nil , err
54+ }
5255 action = simulateHandleMsgSubmitProposal (msg , sk , handler , ctx , event )
5356 proposalID := k .GetLastProposalID (ctx )
5457 // 2) Schedule operations for votes
@@ -77,9 +80,12 @@ func SimulateSubmittingVotingAndSlashingForProposal(k gov.Keeper, sk stake.Keepe
7780// Note: Currently doesn't ensure that the proposal txt is in JSON form
7881func SimulateMsgSubmitProposal (k gov.Keeper , sk stake.Keeper ) simulation.Operation {
7982 handler := gov .NewHandler (k )
80- return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , log string , event func (string )) (action string , fOps []simulation.FutureOperation , err sdk. Error ) {
83+ return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , event func (string )) (action string , fOps []simulation.FutureOperation , err error ) {
8184 sender := simulation .RandomKey (r , keys )
82- msg := simulationCreateMsgSubmitProposal (tb , r , sender , log )
85+ msg , err := simulationCreateMsgSubmitProposal (tb , r , sender )
86+ if err != nil {
87+ return "" , nil , err
88+ }
8389 action = simulateHandleMsgSubmitProposal (msg , sk , handler , ctx , event )
8490 return action , nil , nil
8591 }
@@ -100,25 +106,25 @@ func simulateHandleMsgSubmitProposal(msg gov.MsgSubmitProposal, sk stake.Keeper,
100106 return action
101107}
102108
103- func simulationCreateMsgSubmitProposal (tb testing.TB , r * rand.Rand , sender crypto.PrivKey , log string ) gov.MsgSubmitProposal {
109+ func simulationCreateMsgSubmitProposal (tb testing.TB , r * rand.Rand , sender crypto.PrivKey ) ( msg gov.MsgSubmitProposal , err error ) {
104110 addr := sdk .AccAddress (sender .PubKey ().Address ())
105111 deposit := randomDeposit (r )
106- msg : = gov .NewMsgSubmitProposal (
112+ msg = gov .NewMsgSubmitProposal (
107113 simulation .RandStringOfLength (r , 5 ),
108114 simulation .RandStringOfLength (r , 5 ),
109115 gov .ProposalTypeText ,
110116 addr ,
111117 deposit ,
112118 )
113119 if msg .ValidateBasic () != nil {
114- tb . Fatalf ("expected msg to pass ValidateBasic: %s, log %s " , msg .GetSignBytes (), log )
120+ err = fmt . Errorf ("expected msg to pass ValidateBasic: %s" , msg .GetSignBytes ())
115121 }
116- return msg
122+ return
117123}
118124
119125// SimulateMsgDeposit
120126func SimulateMsgDeposit (k gov.Keeper , sk stake.Keeper ) simulation.Operation {
121- return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , log string , event func (string )) (action string , fOp []simulation.FutureOperation , err sdk. Error ) {
127+ return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , event func (string )) (action string , fOp []simulation.FutureOperation , err error ) {
122128 key := simulation .RandomKey (r , keys )
123129 addr := sdk .AccAddress (key .PubKey ().Address ())
124130 proposalID , ok := randomProposalID (r , k , ctx )
@@ -128,7 +134,7 @@ func SimulateMsgDeposit(k gov.Keeper, sk stake.Keeper) simulation.Operation {
128134 deposit := randomDeposit (r )
129135 msg := gov .NewMsgDeposit (addr , proposalID , deposit )
130136 if msg .ValidateBasic () != nil {
131- tb . Fatalf ("expected msg to pass ValidateBasic: %s, log %s " , msg .GetSignBytes (), log )
137+ return "" , nil , fmt . Errorf ("expected msg to pass ValidateBasic: %s" , msg .GetSignBytes ())
132138 }
133139 ctx , write := ctx .CacheContext ()
134140 result := gov .NewHandler (k )(ctx , msg )
@@ -153,7 +159,7 @@ func SimulateMsgVote(k gov.Keeper, sk stake.Keeper) simulation.Operation {
153159
154160// nolint: unparam
155161func operationSimulateMsgVote (k gov.Keeper , sk stake.Keeper , key crypto.PrivKey , proposalID int64 ) simulation.Operation {
156- return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , log string , event func (string )) (action string , fOp []simulation.FutureOperation , err sdk. Error ) {
162+ return func (tb testing.TB , r * rand.Rand , app * baseapp.BaseApp , ctx sdk.Context , keys []crypto.PrivKey , event func (string )) (action string , fOp []simulation.FutureOperation , err error ) {
157163 if key == nil {
158164 key = simulation .RandomKey (r , keys )
159165 }
@@ -168,7 +174,7 @@ func operationSimulateMsgVote(k gov.Keeper, sk stake.Keeper, key crypto.PrivKey,
168174 option := randomVotingOption (r )
169175 msg := gov .NewMsgVote (addr , proposalID , option )
170176 if msg .ValidateBasic () != nil {
171- tb . Fatalf ("expected msg to pass ValidateBasic: %s, log %s " , msg .GetSignBytes (), log )
177+ return "" , nil , fmt . Errorf ("expected msg to pass ValidateBasic: %s" , msg .GetSignBytes ())
172178 }
173179 ctx , write := ctx .CacheContext ()
174180 result := gov .NewHandler (k )(ctx , msg )
0 commit comments