forked from skip-mev/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoracle_test.go
77 lines (67 loc) · 1.99 KB
/
oracle_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
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
package oracle_test
import (
"math/rand"
"testing"
"time"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/skip-mev/slinky/oracle/config"
"github.com/skip-mev/slinky/oracle/types"
)
var (
providerCfg1 = config.ProviderConfig{
Name: "api1",
API: config.APIConfig{
Interval: 500 * time.Millisecond,
Timeout: 250 * time.Millisecond,
ReconnectTimeout: 250 * time.Millisecond,
MaxQueries: 10,
Enabled: true,
Name: "api1",
Endpoints: []config.Endpoint{{URL: "http://test.com"}},
},
Type: "price_provider",
}
providerCfg2 = config.ProviderConfig{
Name: "websocket1",
WebSocket: config.WebSocketConfig{
MaxBufferSize: 10,
Enabled: true,
ReconnectionTimeout: 250 * time.Millisecond,
Endpoints: []config.Endpoint{
{
URL: "ws://localhost:8080",
},
},
Name: "websocket1",
ReadBufferSize: config.DefaultReadBufferSize,
WriteBufferSize: config.DefaultWriteBufferSize,
HandshakeTimeout: config.DefaultHandshakeTimeout,
EnableCompression: config.DefaultEnableCompression,
ReadTimeout: config.DefaultReadTimeout,
WriteTimeout: config.DefaultWriteTimeout,
PingInterval: config.DefaultPingInterval,
MaxSubscriptionsPerConnection: config.DefaultMaxSubscriptionsPerConnection,
},
Type: "price_provider",
}
)
type OracleTestSuite struct {
suite.Suite
random *rand.Rand
logger *zap.Logger
// Oracle config
currencyPairs []types.ProviderTicker
}
func TestOracleSuite(t *testing.T) {
suite.Run(t, new(OracleTestSuite))
}
func (s *OracleTestSuite) SetupTest() {
s.random = rand.New(rand.NewSource(time.Now().UnixNano()))
s.logger = zap.NewExample()
s.currencyPairs = []types.ProviderTicker{
types.NewProviderTicker("BTC/USD", "{}"),
types.NewProviderTicker("ETH/USD", "{}"),
types.NewProviderTicker("ATOM/USD", "{}"),
}
}