mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 10:04:01 +03:00
Add antireplay cache mock
This commit is contained in:
@@ -16,7 +16,7 @@ func (s *stableBloomFilter) SeenBefore(digest []byte) bool {
|
||||
|
||||
func NewStableBloomFilter(byteSize uint, errorRate float64) mtglib.AntiReplayCache {
|
||||
sf := boom.NewDefaultStableBloomFilter(byteSize*8, errorRate) // nolint: gomnd
|
||||
sf.SetHash(xxhash.New64())
|
||||
sf.SetHash(xxhash.New64())
|
||||
|
||||
return &stableBloomFilter{
|
||||
filter: *sf,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package testlib
|
||||
|
||||
import "github.com/stretchr/testify/mock"
|
||||
|
||||
type MtglibAntiReplayCacheMock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *MtglibAntiReplayCacheMock) SeenBefore(data []byte) bool {
|
||||
return m.Called(data).Bool(0)
|
||||
}
|
||||
@@ -13,14 +13,14 @@ type MtglibNetworkMock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (n *MtglibNetworkMock) Dial(network, address string) (net.Conn, error) {
|
||||
args := n.Called(network, address)
|
||||
func (m *MtglibNetworkMock) Dial(network, address string) (net.Conn, error) {
|
||||
args := m.Called(network, address)
|
||||
|
||||
return args.Get(0).(net.Conn), args.Error(1)
|
||||
}
|
||||
|
||||
func (n *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
args := n.Called(ctx, network, address)
|
||||
func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
args := m.Called(ctx, network, address)
|
||||
|
||||
return args.Get(0).(net.Conn), args.Error(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user