aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-04-27 06:49:49 +0800
committerFelix Lange <fjl@twurst.com>2015-04-30 21:02:23 +0800
commitd457a1187dbbbf08bcce437789732dab02a73b0f (patch)
treed1a14c292562a3af3e1de2f437a006d9b2d95f95 /common
parent72ab6d325555c742c6b70202d865ec23b50734d6 (diff)
downloaddexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar.gz
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar.bz2
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar.lz
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar.xz
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.tar.zst
dexon-d457a1187dbbbf08bcce437789732dab02a73b0f.zip
common: add Hash.Generate
Diffstat (limited to 'common')
-rw-r--r--common/types.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/types.go b/common/types.go
index daefcde11..183d48fb3 100644
--- a/common/types.go
+++ b/common/types.go
@@ -1,6 +1,10 @@
package common
-import "math/big"
+import (
+ "math/big"
+ "math/rand"
+ "reflect"
+)
const (
hashLength = 32
@@ -48,6 +52,15 @@ func (h *Hash) Set(other Hash) {
}
}
+// Generate implements testing/quick.Generator.
+func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value {
+ m := rand.Intn(len(h))
+ for i := len(h) - 1; i > m; i-- {
+ h[i] = byte(rand.Uint32())
+ }
+ return reflect.ValueOf(h)
+}
+
/////////// Address
func BytesToAddress(b []byte) Address {
var a Address