forked from preichenberger/go-coinbasepro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_test.go
129 lines (111 loc) · 2.46 KB
/
account_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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package coinbasepro
import (
"errors"
"testing"
)
func TestGetAccounts(t *testing.T) {
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
// Check for decoding issues
for _, a := range accounts {
if StructHasZeroValues(a) {
t.Error(errors.New("Zero value"))
}
}
}
func TestGetAccount(t *testing.T) {
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
account, err := client.GetAccount(a.ID)
if err != nil {
t.Error(err)
}
// Check for decoding issues
if StructHasZeroValues(account) {
t.Error(errors.New("Zero value"))
}
}
}
func TestGetCoinbaseAccounts(t *testing.T) {
client := NewTestClient()
accounts, err := client.GetCoinbaseAccounts()
if err != nil {
t.Error(err)
}
if len(accounts) == 0 {
t.Error(errors.New("No accounts found"))
}
sandboxAccounts := map[string]int{
"Fake": 1,
"All the Ether": 1,
"USDC Wallet": 1,
"BAT Wallet": 1,
"EUR Wallet": 1,
"GBP Wallet": 1,
"Zero Hero": 1,
"LINK Wallet": 1,
}
var totalNames int
for _, a := range accounts {
totalNames += sandboxAccounts[a.Name]
}
if totalNames != len(sandboxAccounts) {
t.Error(errors.New("Wrong sandbox account names"))
}
}
func TestListAccountLedger(t *testing.T) {
var ledgers []LedgerEntry
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
cursor := client.ListAccountLedger(a.ID)
for cursor.HasMore {
if err := cursor.NextPage(&ledgers); err != nil {
t.Error(err)
}
for _, ledger := range ledgers {
props := []string{"ID", "CreatedAt", "Amount", "Balance", "Type"}
if err := EnsureProperties(ledger, props); err != nil {
t.Error(err)
}
if ledger.Type == "match" || ledger.Type == "fee" {
if err := Ensure(ledger.Details); err != nil {
t.Error(errors.New("Details is missing"))
}
}
}
}
}
}
func TestListHolds(t *testing.T) {
var holds []Hold
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
cursor := client.ListHolds(a.ID)
for cursor.HasMore {
if err := cursor.NextPage(&holds); err != nil {
t.Error(err)
}
for _, h := range holds {
// Check for decoding issues
if StructHasZeroValues(h) {
t.Error(errors.New("Zero value"))
}
}
}
}
}