|
|
@ -1,6 +1,10 @@ |
|
|
|
package common |
|
|
|
package common |
|
|
|
|
|
|
|
|
|
|
|
import "math/big" |
|
|
|
import ( |
|
|
|
|
|
|
|
"math/big" |
|
|
|
|
|
|
|
"math/rand" |
|
|
|
|
|
|
|
"reflect" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
hashLength = 32 |
|
|
|
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
|
|
|
|
/////////// Address
|
|
|
|
func BytesToAddress(b []byte) Address { |
|
|
|
func BytesToAddress(b []byte) Address { |
|
|
|
var a Address |
|
|
|
var a Address |
|
|
|