-
Notifications
You must be signed in to change notification settings - Fork 95
/
mock.go
41 lines (36 loc) · 961 Bytes
/
mock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package common
import (
"encoding/hex"
"fmt"
"github.com/vitelabs/go-vite/common/types"
)
func MockAddress(i int) types.Address {
base := "00000000000000000fff" + fmt.Sprintf("%0*d", 6, i) + "fff00000000000"
bytes, _ := hex.DecodeString(base)
addresses, _ := types.BytesToAddress(bytes)
return addresses
}
func MockHash(i int) types.Hash {
base := "0000000000000000000000000000fff" + fmt.Sprintf("%0*d", 6, i) + "fff000000000000000000000000"
bytes, err := hex.DecodeString(base)
if err != nil {
panic(err)
}
addresses, err := types.BytesToHash(bytes)
if err != nil {
panic(err)
}
return addresses
}
func MockHashBy(i1 int, i int) types.Hash {
base := fmt.Sprintf("%0*d", 6, i1) + "0000000000000000000000fff" + fmt.Sprintf("%0*d", 6, i) + "fff000000000000000000000000"
bytes, err := hex.DecodeString(base)
if err != nil {
panic(err)
}
addresses, err := types.BytesToHash(bytes)
if err != nil {
panic(err)
}
return addresses
}