Skip to content

Commit 717e2e6

Browse files
committed
Further changes to support go 1.15
Signed-off-by: Paulo Gomes <[email protected]>
1 parent 656c234 commit 717e2e6

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

test/collisiondetection_test.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package test
22

33
import (
4-
"bytes"
54
"encoding/hex"
65
"fmt"
7-
"os"
6+
"io/ioutil"
87
"strings"
98
"testing"
109

@@ -66,7 +65,7 @@ func TestCollisionDetection(t *testing.T) {
6665
for _, tt := range tests {
6766
for i, d := range tt.hashers {
6867
t.Run(fmt.Sprintf("%s[%d]", tt.name, i), func(t *testing.T) {
69-
data, err := os.ReadFile(tt.inputFile)
68+
data, err := ioutil.ReadFile(tt.inputFile)
7069
if err != nil {
7170
t.Fatalf("unexpected error: %v", err)
7271
}
@@ -86,29 +85,6 @@ func TestCollisionDetection(t *testing.T) {
8685
}
8786
}
8887

89-
func FuzzDeviationDetection(f *testing.F) {
90-
f.Add([]byte{})
91-
92-
g := sha1cd.New().(sha1cd.CollisionResistantHash)
93-
c := cgo.New().(sha1cd.CollisionResistantHash)
94-
95-
f.Fuzz(func(t *testing.T, in []byte) {
96-
g.Reset()
97-
c.Reset()
98-
99-
g.Write(in)
100-
c.Write(in)
101-
102-
gv, gc := g.CollisionResistantSum(nil)
103-
cv, cc := c.CollisionResistantSum(nil)
104-
105-
if bytes.Compare(gv, cv) != 0 || gc != cc {
106-
t.Fatalf("input: %q\n go result: %q %v\ncgo result: %q %v",
107-
hex.EncodeToString(in), hex.EncodeToString(gv), gc, hex.EncodeToString(cv), cc)
108-
}
109-
})
110-
}
111-
11288
func TestCalculateDvMask_Shattered1(t *testing.T) {
11389
for i := range testdata.Shattered1M1s {
11490
t.Run(fmt.Sprintf("m1[%d]", i), func(t *testing.T) {

test/fuzz_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//go:build gofuzz
2+
// +build gofuzz
3+
4+
package test
5+
6+
import (
7+
"bytes"
8+
"encoding/hex"
9+
"testing"
10+
11+
"github.com/pjbgf/sha1cd"
12+
"github.com/pjbgf/sha1cd/cgo"
13+
)
14+
15+
func FuzzDeviationDetection(f *testing.F) {
16+
f.Add([]byte{})
17+
18+
g := sha1cd.New().(sha1cd.CollisionResistantHash)
19+
c := cgo.New().(sha1cd.CollisionResistantHash)
20+
21+
f.Fuzz(func(t *testing.T, in []byte) {
22+
g.Reset()
23+
c.Reset()
24+
25+
g.Write(in)
26+
c.Write(in)
27+
28+
gv, gc := g.CollisionResistantSum(nil)
29+
cv, cc := c.CollisionResistantSum(nil)
30+
31+
if bytes.Compare(gv, cv) != 0 || gc != cc {
32+
t.Fatalf("input: %q\n go result: %q %v\ncgo result: %q %v",
33+
hex.EncodeToString(in), hex.EncodeToString(gv), gc, hex.EncodeToString(cv), cc)
34+
}
35+
})
36+
}

0 commit comments

Comments
 (0)