-
Notifications
You must be signed in to change notification settings - Fork 10
/
api_nutlink_test.go
98 lines (84 loc) · 3.17 KB
/
api_nutlink_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
package blockfrost_test
import (
"context"
"path/filepath"
"strings"
"testing"
"github.com/blockfrost/blockfrost-go"
)
func TestNutlinkAddressUnMarshall(t *testing.T) {
fp := filepath.Join(testdata, "json", "nutlink", "address.json")
want := blockfrost.NutlinkAddress{
Address: "addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz",
MetadataUrl: "https://nut.link/metadata.json",
MetadataHash: "6bf124f217d0e5a0a8adb1dbd8540e1334280d49ab861127868339f43b3948af",
Metadata: blockfrost.NutlinkAddressMeta{},
}
got := blockfrost.NutlinkAddress{}
testStructGotWant(t, fp, &got, &want)
}
func TestTickerUnmarshal(t *testing.T) {
fp := filepath.Join(testdata, "json", "nutlink", "ticker.json")
want := blockfrost.Ticker{Name: "ADAUSD", Count: 1980038, LatestBlock: 2657092}
got := blockfrost.Ticker{}
testStructGotWant(t, fp, &got, &want)
}
func TestTickerRecordUnmarshal(t *testing.T) {
fp := filepath.Join(testdata, "json", "nutlink", "ticker_records.json")
want := []blockfrost.TickerRecord{
{
TxHash: "e8073fd5318ff43eca18a852527166aa8008bee9ee9e891f585612b7e4ba700b",
BlockHeight: 2657092,
TxIndex: 8,
},
}
got := []blockfrost.TickerRecord{}
testStructGotWant(t, fp, &got, &want)
}
func TestNutlinkIntegration(t *testing.T) {
api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{})
addr := "addr1qygvjldfxxhp7q96w729c6gvq7hy6pfc937jqlvpms2833rah0c4wey5zfgnuar9eyf6q7pzjzv56c542q7zctpkz9wqay69js"
got, err := api.Nutlink(context.TODO(), addr)
if err != nil {
t.Fatal(err)
}
fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden")
want := blockfrost.NutlinkAddress{}
testIntUtil(t, fp, &got, &want)
}
func TestTickersIntegration(t *testing.T) {
api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{})
addr := "addr1qygvjldfxxhp7q96w729c6gvq7hy6pfc937jqlvpms2833rah0c4wey5zfgnuar9eyf6q7pzjzv56c542q7zctpkz9wqay69js"
got, err := api.Tickers(context.TODO(), addr, blockfrost.APIQueryParams{Count: 5})
if err != nil {
t.Fatal(err)
}
fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden")
want := []blockfrost.Ticker{}
testIntUtil(t, fp, &got, &want)
}
func TestTickerRecordsIntegration(t *testing.T) {
api := blockfrost.NewAPIClient(
blockfrost.APIClientOptions{},
)
got, err := api.TickerRecords(context.TODO(), "ADAUSD", blockfrost.APIQueryParams{Count: 5})
if err != nil {
t.Fatal(err)
}
fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden")
want := []blockfrost.TickerRecord{}
testIntUtil(t, fp, &got, &want)
}
func TestAddressTickerRecordsIntegration(t *testing.T) {
api := blockfrost.NewAPIClient(
blockfrost.APIClientOptions{},
)
addr := "addr1qygvjldfxxhp7q96w729c6gvq7hy6pfc937jqlvpms2833rah0c4wey5zfgnuar9eyf6q7pzjzv56c542q7zctpkz9wqay69js"
got, err := api.AddressTickerRecords(context.TODO(), addr, "ADAUSD", blockfrost.APIQueryParams{Count: 5})
if err != nil {
t.Fatal(err)
}
fp := filepath.Join(testdata, strings.ToLower(strings.TrimPrefix(t.Name(), "Test"))+".golden")
want := []blockfrost.TickerRecord{}
testIntUtil(t, fp, &got, &want)
}