mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 05:46:32 +00:00
libs/common: refactor libs/common 2 (#4231)
* libs/common: refactor libs/common 2 - move random function to there own pkg Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * change imports and usage throughout repo * fix goimports * add changelog entry
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
)
|
||||
|
||||
// Contract: !bytes.Equal(input, output) && len(input) >= len(output)
|
||||
@@ -17,11 +17,11 @@ func MutateByteSlice(bytez []byte) []byte {
|
||||
bytez = mBytez
|
||||
|
||||
// Try a random mutation
|
||||
switch cmn.RandInt() % 2 {
|
||||
switch rand.RandInt() % 2 {
|
||||
case 0: // Mutate a single byte
|
||||
bytez[cmn.RandInt()%len(bytez)] += byte(cmn.RandInt()%255 + 1)
|
||||
bytez[rand.RandInt()%len(bytez)] += byte(rand.RandInt()%255 + 1)
|
||||
case 1: // Remove an arbitrary byte
|
||||
pos := cmn.RandInt() % len(bytez)
|
||||
pos := rand.RandInt() % len(bytez)
|
||||
bytez = append(bytez[:pos], bytez[pos+1:]...)
|
||||
}
|
||||
return bytez
|
||||
|
||||
Reference in New Issue
Block a user