Update randomfees selection of non-zero coins (#8209)
* Update randomfees selection of non-zero coins * fix randomfees * fixing account test * fix broadcast.go * fixing * Revert "fixing" This reverts commit b6eaa8d281977451d95e3f5e17792bef642ff65c. * Revert "fix broadcast.go" This reverts commit 2275ea1303b3f5f8c61774a42f17d8a539c3c00a. * Revert "fixing account test" This reverts commit d0d4aa7d5d9421b810bd6582db33ea7dda66a008. * fix randomfees * fix randomfees * remove commented code Co-authored-by: Likhita Polavarapu <likhita@vitwit.xyz> Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
This commit is contained in:
parent
cfeb5eb4d0
commit
d316013f77
@ -1,6 +1,7 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
@ -70,11 +71,17 @@ func RandomFees(r *rand.Rand, ctx sdk.Context, spendableCoins sdk.Coins) (sdk.Co
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
denomIndex := r.Intn(len(spendableCoins))
|
||||
randCoin := spendableCoins[denomIndex]
|
||||
perm := r.Perm(len(spendableCoins))
|
||||
var randCoin sdk.Coin
|
||||
for _, index := range perm {
|
||||
randCoin = spendableCoins[index]
|
||||
if !randCoin.Amount.IsZero() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if randCoin.Amount.IsZero() {
|
||||
return nil, nil
|
||||
return nil, fmt.Errorf("no coins found for random fees")
|
||||
}
|
||||
|
||||
amt, err := RandPositiveInt(r, randCoin.Amount)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user