4 . "github.com/tendermint/tmlibs/common"
7 // Contract: !bytes.Equal(input, output) && len(input) >= len(output)
8 func MutateByteSlice(bytez []byte) []byte {
9 // If bytez is empty, panic
11 panic("Cannot mutate an empty bytez")
15 mBytez := make([]byte, len(bytez))
19 // Try a random mutation
20 switch RandInt() % 2 {
21 case 0: // Mutate a single byte
22 bytez[RandInt()%len(bytez)] += byte(RandInt()%255 + 1)
23 case 1: // Remove an arbitrary byte
24 pos := RandInt() % len(bytez)
25 bytez = append(bytez[:pos], bytez[pos+1:]...)