github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/account_test.go (about) 1 package bitfinex 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 "testing" 8 ) 9 10 func TestAccountInfo(t *testing.T) { 11 httpDo = func(req *http.Request) (*http.Response, error) { 12 msg := `[{ 13 "maker_fees":"0.1", 14 "taker_fees":"0.2", 15 "fees":[{ 16 "pairs":"BTC", 17 "maker_fees":"0.1", 18 "taker_fees":"0.2" 19 },{ 20 "pairs":"LTC", 21 "maker_fees":"0.1", 22 "taker_fees":"0.2" 23 },{ 24 "pairs":"ETH", 25 "maker_fees":"0.1", 26 "taker_fees":"0.2" 27 }] 28 }]` 29 30 resp := http.Response{ 31 Body: ioutil.NopCloser(bytes.NewBufferString(msg)), 32 StatusCode: 200, 33 } 34 return &resp, nil 35 } 36 37 info, err := NewClient().Account.Info() 38 39 if err != nil { 40 t.Error(err) 41 } 42 43 if len(info.Fees) != 3 { 44 t.Error("Expected", 3) 45 t.Error("Actual ", len(info.Fees)) 46 } 47 } 48 49 func TestAccountKeyPermission(t *testing.T) { 50 httpDo = func(req *http.Request) (*http.Response, error) { 51 msg := `{ 52 "account":{ 53 "read":true, 54 "write":false 55 }, 56 "history":{ 57 "read":true, 58 "write":false 59 }, 60 "orders":{ 61 "read":true, 62 "write":true 63 }, 64 "positions":{ 65 "read":true, 66 "write":true 67 }, 68 "funding":{ 69 "read":true, 70 "write":true 71 }, 72 "wallets":{ 73 "read":true, 74 "write":true 75 }, 76 "withdraw":{ 77 "read":null, 78 "write":null 79 } 80 }` 81 82 resp := http.Response{ 83 Body: ioutil.NopCloser(bytes.NewBufferString(msg)), 84 StatusCode: 200, 85 } 86 return &resp, nil 87 } 88 perm, err := NewClient().Account.KeyPermission() 89 90 if err != nil { 91 t.Error(err) 92 } 93 94 if !perm.Account.Read { 95 t.Error("Expected", true) 96 t.Error("Actual ", perm.Account.Read) 97 } 98 99 if perm.History.Write { 100 t.Error("Expected", false) 101 t.Error("Actual ", perm.History.Write) 102 } 103 }