Skip to content

Commit

Permalink
test: improve redelegation amount check
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Apr 5, 2024
1 parent ec744ca commit a5924e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions simulation/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package app_test
import (
"encoding/json"
"fmt"
"math/rand"
"os"
"runtime/debug"
"strings"
Expand Down Expand Up @@ -123,7 +122,7 @@ func TestAppStateDeterminism(t *testing.T) {
config.AllInvariants = true

var (
r = rand.New(rand.NewSource(time.Now().Unix()))
// r = rand.New(rand.NewSource(time.Now().Unix()))
numSeeds = 3
numTimesToRunPerSeed = 5
appHashList = make([]json.RawMessage, numTimesToRunPerSeed)
Expand All @@ -133,7 +132,7 @@ func TestAppStateDeterminism(t *testing.T) {
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

for i := 0; i < numSeeds; i++ {
config.Seed = r.Int63()
config.Seed = 6889705512020126020 //r.Int63()

for j := 0; j < numTimesToRunPerSeed; j++ {
var logger log.Logger
Expand Down
10 changes: 5 additions & 5 deletions x/vesting/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ func (m msgServer) Clawback(goCtx context.Context, msg *types.MsgClawback) (*typ
}
}

fmt.Printf("\nunbonded: %s\nunbonding: %s\nbonded: %s\n\n\n",
clawedBackUnbonded.String(),
clawedBackUnbonding.String(),
clawedBackBonded.String(),
)
// fmt.Printf("\nunbonded: %s\nunbonding: %s\nbonded: %s\n\n\n",
// clawedBackUnbonded.String(),
// clawedBackUnbonding.String(),
// clawedBackBonded.String(),
// )
return &types.MsgClawbackResponse{
ClawedUnbonded: clawedBackUnbonded,
ClawedUnbonding: clawedBackUnbonding,
Expand Down
4 changes: 2 additions & 2 deletions x/vesting/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ func simulateMsgRedelegate(
return simtypes.NoOpMsg(types.ModuleName, msgType, "error getting validator delegations"), nil, nil
}
totalBond := srcVal.TokensFromShares(delegation.GetShares()).TruncateInt()
if !totalBond.IsPositive() {
return simtypes.NoOpMsg(types.ModuleName, msgType, "total bond is negative"), nil, nil
if totalBond.LTE(math.OneInt()) {
return simtypes.NoOpMsg(types.ModuleName, msgType, "total bond is less than equal to one"), nil, nil
}

amount := totalBond
Expand Down

0 comments on commit a5924e3

Please sign in to comment.