-
Notifications
You must be signed in to change notification settings - Fork 6
/
suite.go
105 lines (90 loc) · 2.23 KB
/
suite.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package mock
import (
"crypto/cipher"
"github.com/ElrondNetwork/elrond-go-crypto"
)
// SuiteMock -
type SuiteMock struct {
StringStub func() string
ScalarLenStub func() int
CreateScalarStub func() crypto.Scalar
PointLenStub func() int
CreatePointStub func() crypto.Point
CreatePointForScalarStub func(scalar crypto.Scalar) (crypto.Point, error)
RandomStreamStub func() cipher.Stream
CreateKeyPairStub func() (crypto.Scalar, crypto.Point)
IsPointValidStub func([]byte) error
GetUnderlyingSuiteStub func() interface{}
}
// String -
func (s *SuiteMock) String() string {
if s.StringStub != nil {
return s.StringStub()
}
return "mock suite"
}
// ScalarLen -
func (s *SuiteMock) ScalarLen() int {
if s.ScalarLenStub != nil {
return s.ScalarLenStub()
}
return 32
}
// CreateScalar -
func (s *SuiteMock) CreateScalar() crypto.Scalar {
if s.CreateScalarStub != nil {
return s.CreateScalarStub()
}
return nil
}
// PointLen -
func (s *SuiteMock) PointLen() int {
if s.PointLenStub != nil {
return s.PointLenStub()
}
return 64
}
// CreatePoint -
func (s *SuiteMock) CreatePoint() crypto.Point {
if s.CreatePointStub != nil {
return s.CreatePointStub()
}
return nil
}
// CreatePointForScalar -
func (s *SuiteMock) CreatePointForScalar(scalar crypto.Scalar) (crypto.Point, error) {
if s.CreatePointForScalarStub != nil {
return s.CreatePointForScalarStub(scalar)
}
return nil, nil
}
// RandomStream -
func (s *SuiteMock) RandomStream() cipher.Stream {
stream := NewStreamer()
return stream
}
// GetUnderlyingSuite -
func (s *SuiteMock) GetUnderlyingSuite() interface{} {
if s.GetUnderlyingSuiteStub != nil {
return s.GetUnderlyingSuiteStub()
}
return "invalid suite"
}
// CreateKeyPair -
func (s *SuiteMock) CreateKeyPair() (crypto.Scalar, crypto.Point) {
if s.CreateKeyPairStub != nil {
return s.CreateKeyPairStub()
}
return nil, nil
}
// CheckPointValid -
func (s *SuiteMock) CheckPointValid(pointBytes []byte) error {
if s.IsPointValidStub != nil {
return s.IsPointValidStub(pointBytes)
}
return nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (s *SuiteMock) IsInterfaceNil() bool {
return s == nil
}