-
Notifications
You must be signed in to change notification settings - Fork 0
/
crash_test.go
49 lines (43 loc) · 929 Bytes
/
crash_test.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
42
43
44
45
46
47
48
49
package vero
import (
"strconv"
"testing"
"github.com/pastc/vero/v2/internal"
)
func TestCrash(t *testing.T) {
houseEdge := 6.66
tests := []struct {
serverSeed string
want struct {
value int
}
}{
{"964cd1665174434d3b82b0a7e9dd5b8bbbc58056a4c3d411d89afcdc2141fa81", struct {
value int
}{230}},
{"ad0111b329b54e2947d1ee14c7b40242019bae11114775932b7865c227636a3a", struct {
value int
}{1034}},
}
for _, tt := range tests {
t.Run(tt.serverSeed, func(t *testing.T) {
value, err := Crash(tt.serverSeed, houseEdge)
if err != nil {
t.Fatalf("got %v", err)
}
if value != tt.want.value {
t.Errorf("got %d, want %d", value, tt.want.value)
}
})
}
}
func FuzzCrash(f *testing.F) {
houseEdge := 6.66
f.Add(0)
f.Fuzz(func(t *testing.T, seed int) {
_, err := Crash(internal.Hash256(strconv.Itoa(seed)), houseEdge)
if err != nil {
t.Fatalf("got %v", err)
}
})
}