-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpool_test.go
60 lines (53 loc) · 1.83 KB
/
pool_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
package client
import (
"context"
"fmt"
"github.com/google/go-cmp/cmp"
"net/http"
"testing"
)
func TestPoolsService(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/project_code/pools", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"data": [{ "address":"0x0000", "pool_components":[{"name":"DePo"}]}], "error_code": 0 }`)
})
mux.HandleFunc("/pools", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"data": [{ "address":"0x0001", "pool_components":[{"name":"DePo"}]}], "error_code": 0 }`)
})
t.Run("ListByProjectCode", func(t *testing.T) {
opt := &PoolListOptions{
ListOptions{Chain: "bsc"},
}
ctx := context.Background()
pools, _, err := client.Pools.ListByProjectCode(ctx, "project_code", opt)
if err != nil {
t.Errorf("Pools.ListByProjectCode returned error: %v", err)
}
fmt.Println(pools)
want := []*Pool{{Address: "0x0000", Type: "", PoolIndex: 0, ProjectCode: "", PoolComponents: []PoolComponent{{TokenAddress: "", Type: ""}}}}
if !cmp.Equal(pools, want) {
t.Errorf("Pool.List returned %+v, want %+v", pools, want)
}
})
t.Run("ListByAddresses", func(t *testing.T) {
opt := &PoolListByAddressesOptions{
ListOptions: ListOptions{Chain: "bsc"},
Addresses: []string{
"0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
"0x0ed7e52944161450477ee417de9cd3a859b14fd0",
},
}
ctx := context.Background()
pools, _, err := client.Pools.ListByAddresses(ctx, opt)
if err != nil {
t.Errorf("Pools.ListByAddresses returned error: %v", err)
}
want := []*Pool{{Address: "0x0001", Type: "", PoolIndex: 0, ProjectCode: "", PoolComponents: []PoolComponent{{TokenAddress: "", Type: ""}}}}
if !cmp.Equal(pools, want) {
t.Errorf("Pool.List returned %+v, want %+v", pools, want)
}
})
}