-
Notifications
You must be signed in to change notification settings - Fork 6
/
bitstamp_test.go
65 lines (59 loc) · 1.3 KB
/
bitstamp_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
package bitstamp
import (
"fmt"
"os"
"syscall"
"testing"
)
func Init() (api *Api) {
filename := os.ExpandEnv("$BITSTAMP_CONFIG")
if filename == "" {
fmt.Println("Please set $BITSTAMP_CONFIG to a proper configuration file")
syscall.Exit(0)
}
api, err := NewFromConfig(filename)
if err != nil {
panic(err)
}
return
}
func TestTicker(t *testing.T) {
api := Init()
ticker, err := api.GetTicker()
if err != nil {
t.Errorf("Could not fetch ticker :", err)
}
if ticker.Last == 0 {
t.Errorf("Ticker probably wrongly filled")
}
}
func TestOrderBook(t *testing.T) {
api := Init()
orderbook, err := api.GetOrderBook()
if err != nil {
t.Errorf("Could not fetch orderbook :", err)
}
if orderbook.Orders[0].Price == 0. {
t.Errorf("Orderbook probably wrongly filled")
}
}
func TestTrades(t *testing.T) {
api := Init()
trades, err := api.GetTrades()
if err != nil {
t.Errorf("Could not fetch trades :", err)
}
if len(trades) == 0 || trades[0].Price == 0. {
t.Errorf("trades probably wrongly filled")
}
}
func TestTradesParams(t *testing.T) {
api := Init()
trades, err := api.GetTradesParams(1, 10, "desc")
if err != nil {
t.Errorf("Could not fetch trades with params:", err)
}
if len(trades) == 0 || trades[0].Price == 0. {
t.Errorf("trades with params probably wrongly filled")
}
}