-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtx_test.go
82 lines (61 loc) · 2.21 KB
/
tx_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
package coinpayments_test
import (
"fmt"
"testing"
"github.com/jeffwalsh/go-coinpayments"
)
func TestCallGetTxInfo(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatal("should have instantiated a new client with valid configuration")
}
resp, err := client.CallGetTxInfo(&coinpayments.TxInfoRequest{TxID: "CPCH3A2HBY7R92IOCQNYPL1G8X", Full: "0"})
if err != nil {
t.Fatal("error getting tx info ", err)
}
fmt.Printf("%+v\n", resp)
}
func TestCallCreateTransaction(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}
resp, err := client.CallCreateTransaction(&coinpayments.TransactionRequest{Amount: "100", Currency1: "USD", Currency2: "BTC", BuyerEmail: "jeff@internet.com"})
if err != nil {
t.Fatalf("Could not call create transaction: %s", err.Error())
}
_, err = client.CallGetTxInfo(&coinpayments.TxInfoRequest{TxID: resp.TxnID})
if err != nil {
t.Fatalf("Could not call get tx info: %s", err.Error())
}
}
func TestCallGetCallbackAddress(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}
_, err = client.CallGetCallbackAddress(&coinpayments.CallbackAddressRequest{Currency: "BTC"})
if err != nil {
t.Fatalf("Could not call get callback address: %s", err.Error())
}
}
func TestCallGetDepositAddress(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}
_, err = client.CallGetDepositAddress(&coinpayments.DepositAddressRequest{Currency: "BTC"})
if err != nil {
t.Fatalf("Could not call get callback address: %s", err.Error())
}
}
func TestCallGetTxList(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}
_, err = client.CallGetTxList(&coinpayments.TxListRequest{})
if err != nil {
t.Fatalf("Could not call get tx list: %s", err.Error())
}
}