Skip to content

Commit

Permalink
fix: shuffling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok committed Aug 13, 2024
1 parent 848633e commit 878543a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions testing/pkg/tests/preconf/preconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"math/big"
"math/rand"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -465,9 +466,16 @@ func getRandomBid(

if shouldSlash {
if len(txHashes) > 1 {
rand.Shuffle(len(txHashes), func(i, j int) {
txHashes[i], txHashes[j] = txHashes[j], txHashes[i]
})
original := make([]string, len(txHashes))
copy(original, txHashes)
for {
rand.Shuffle(len(txHashes), func(i, j int) {
txHashes[i], txHashes[j] = txHashes[j], txHashes[i]
})
if !reflect.DeepEqual(original, txHashes) {
break
}
}
} else {
// get random tx hash
randBytes := make([]byte, 32)
Expand Down

0 comments on commit 878543a

Please sign in to comment.