-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdata_test.go
73 lines (61 loc) · 1.28 KB
/
data_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
package market
import (
"fmt"
"testing"
"time"
)
func TestMarketer_MarshalJson(t *testing.T) {
m := NewTestMarketer()
fmt.Println(m.MarshalJson())
}
func TestLister_Del(t *testing.T) {
l := newList()
l.Add("btc", NewTestMarketer())
l.Add("usdt", NewTestMarketer())
l.Del("usdt")
fmt.Println(l)
}
func TestLister_Find(t *testing.T) {
l := newList()
l.Add("btc", NewTestMarketer())
l.Add("usdt", NewTestMarketer())
newL := l.Find("a")
fmt.Println(newL)
}
func TestLister_MarshalJson(t *testing.T) {
l := newList()
l.Add("btc", NewTestMarketer())
l.Add("usdt", NewTestMarketer())
fmt.Println(l.MarshalJson())
}
func NewTestMarketer() *Marketer {
var d = make(Depth, 1)
s := [2]string{"20321", "213"}
d[0] = s
return &Marketer{
BuyFirst: "123213",
SellFirst: "213123",
BuyDepth: d,
SellDepth: d,
Timestamp: time.Duration(time.Now().UnixNano() / 1e6),
}
}
func Test_WriteSubscribing(t *testing.T) {
s := &Subscriber{
Symbol: "ETH-USDT",
MarketType: SpotMarket,
Organize: OkEx,
}
WriteSubscribing <- s
select {
case sub := <-readSubscribing:
Manage.Tasks[sub.Organize].subscribeHandle(sub)
}
}
func Test_WriteRingBuffer(t *testing.T) {
m := NewTestMarketer()
go func() {
writeMarketPool.writeRingBuffer(m)
}()
fmt.Println(<-ReadMarketPool)
}