Skip to content

Commit

Permalink
fix: simulation (no duplicate create validators)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Dec 18, 2024
1 parent 84bbfa1 commit 8a0e723
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions simulation/operations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simulation

import (
"fmt"
"math"
"math/rand"
"os"
Expand Down Expand Up @@ -119,6 +120,18 @@ func SimulateMsgCreateValidator(txGen client.TxConfig, k keeper.Keeper) simtypes
description := generateRandomDescription(r)
commission := generateRandomCommission(r)

vals, err := k.PendingValidators.Get(ctx)
if err != nil {
return simtypes.OperationMsg{}, nil, nil

Check failure on line 125 in simulation/operations.go

View workflow job for this annotation

GitHub Actions / golangci-lint

error is not nil (line 123) but it returns nil (nilerr)
}
for _, v := range vals.Validators {
if v.OperatorAddress == address.String() {
fmt.Println(v.OperatorAddress, address.String())

Check failure on line 129 in simulation/operations.go

View workflow job for this annotation

GitHub Actions / golangci-lint

use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
fmt.Println("skipping due to validator already being in PendingValidators")

Check failure on line 130 in simulation/operations.go

View workflow job for this annotation

GitHub Actions / golangci-lint

use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
return simtypes.OperationMsg{}, nil, nil
}
}

msg, err := poatypes.NewMsgCreateValidator(address.String(), simAccount.ConsKey.PubKey(), description, commission, selfDelegation.Amount)
if err != nil {
return simtypes.NoOpMsg(poatypes.ModuleName, msgType, errors.WithMessage(err, "unable to create MsgCreateValidator").Error()), nil, err
Expand Down

0 comments on commit 8a0e723

Please sign in to comment.