@@ -11,6 +11,8 @@ import (
1111
1212 "github.com/shopspring/decimal"
1313
14+ "github.com/lbryio/lbry.go/extras/errors"
15+
1416 "github.com/lbryio/lbry.go/extras/util"
1517)
1618
@@ -32,7 +34,7 @@ func TestClient_AccountFund(t *testing.T) {
3234 t .Error (err )
3335 return
3436 }
35- balance , err := strconv .ParseFloat (string ( * balanceString ), 64 )
37+ balance , err := strconv .ParseFloat (balanceString . Available . String ( ), 64 )
3638 if err != nil {
3739 t .Error (err )
3840 return
@@ -100,6 +102,35 @@ func TestClient_ChannelList(t *testing.T) {
100102 prettyPrint (* got )
101103}
102104
105+ var channelID string
106+
107+ func TestClient_ChannelCreate (t * testing.T ) {
108+ d := NewClient ("" )
109+ got , err := d .ChannelCreate ("@Test" + fmt .Sprintf ("%d" , time .Now ().Unix ()), 13.37 , ChannelCreateOptions {
110+ ClaimCreateOptions : ClaimCreateOptions {
111+ Title : util .PtrToString ("Mess with the channels" ),
112+ Description : util .PtrToString ("And you'll get what you deserve" ),
113+ Tags : []string {"we" , "got" , "tags" },
114+ Languages : []string {"en-US" },
115+ Locations : []Location {{
116+ Country : util .PtrToString ("CH" ),
117+ State : util .PtrToString ("Ticino" ),
118+ City : util .PtrToString ("Lugano" ),
119+ }},
120+ ThumbnailURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
121+ },
122+ Email :
util .
PtrToString (
"[email protected] " ),
123+ WebsiteURL : util .PtrToString ("https://lbry.com" ),
124+ CoverURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
125+ })
126+ if err != nil {
127+ t .Error (err )
128+ return
129+ }
130+ channelID = got .Outputs [0 ].ClaimID
131+ prettyPrint (* got )
132+ }
133+
103134func TestClient_StreamCreate (t * testing.T ) {
104135 _ = os .Setenv ("BLOCKCHAIN_NAME" , "lbrycrd_regtest" )
105136 d := NewClient ("" )
@@ -142,7 +173,7 @@ func TestClient_StreamCreate(t *testing.T) {
142173 Preview : nil ,
143174 AllowDuplicateName : nil ,
144175 ChannelName : nil ,
145- ChannelID : util .PtrToString ("dd0b559b4f17a7af984f173efb5438534eb6ab27" ),
176+ ChannelID : util .PtrToString (channelID ),
146177 ChannelAccountID : nil ,
147178 })
148179 if err != nil {
@@ -152,35 +183,9 @@ func TestClient_StreamCreate(t *testing.T) {
152183 prettyPrint (* got )
153184}
154185
155- func TestClient_ChannelCreate (t * testing.T ) {
156- d := NewClient ("" )
157- got , err := d .ChannelCreate ("@Test" + fmt .Sprintf ("%d" , time .Now ().Unix ()), 13.37 , ChannelCreateOptions {
158- ClaimCreateOptions : ClaimCreateOptions {
159- Title : util .PtrToString ("Mess with the channels" ),
160- Description : util .PtrToString ("And you'll get what you deserve" ),
161- Tags : []string {"we" , "got" , "tags" },
162- Languages : []string {"en-US" },
163- Locations : []Location {{
164- Country : util .PtrToString ("CH" ),
165- State : util .PtrToString ("Ticino" ),
166- City : util .PtrToString ("Lugano" ),
167- }},
168- ThumbnailURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
169- },
170- Email :
util .
PtrToString (
"[email protected] " ),
171- WebsiteURL : util .PtrToString ("https://lbry.com" ),
172- CoverURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
173- })
174- if err != nil {
175- t .Error (err )
176- return
177- }
178- prettyPrint (* got )
179- }
180-
181186func TestClient_ChannelUpdate (t * testing.T ) {
182187 d := NewClient ("" )
183- got , err := d .ChannelUpdate ("2a8b6d061c5ecb2515f1dd7e04729e9fafac660d" , ChannelUpdateOptions {
188+ got , err := d .ChannelUpdate (channelID , ChannelUpdateOptions {
184189 ClearLanguages : util .PtrToBool (true ),
185190 ClearLocations : util .PtrToBool (true ),
186191 ClearTags : util .PtrToBool (true ),
@@ -264,9 +269,65 @@ func TestClient_ClaimList(t *testing.T) {
264269 prettyPrint (* got )
265270}
266271
272+ func TestClient_SupportTest (t * testing.T ) {
273+ _ = os .Setenv ("BLOCKCHAIN_NAME" , "lbrycrd_regtest" )
274+ d := NewClient ("" )
275+ got , err := d .ChannelCreate ("@Test" + fmt .Sprintf ("%d" , time .Now ().Unix ()), 13.37 , ChannelCreateOptions {
276+ ClaimCreateOptions : ClaimCreateOptions {
277+ Title : util .PtrToString ("Mess with the channels" ),
278+ Description : util .PtrToString ("And you'll get what you deserve" ),
279+ Tags : []string {"we" , "got" , "tags" },
280+ Languages : []string {"en-US" },
281+ Locations : []Location {{
282+ Country : util .PtrToString ("CH" ),
283+ State : util .PtrToString ("Ticino" ),
284+ City : util .PtrToString ("Lugano" ),
285+ }},
286+ ThumbnailURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
287+ },
288+ Email :
util .
PtrToString (
"[email protected] " ),
289+ WebsiteURL : util .PtrToString ("https://lbry.com" ),
290+ CoverURL : util .PtrToString ("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png" ),
291+ })
292+ if err != nil {
293+ t .Error (err )
294+ return
295+ }
296+ time .Sleep (10 * time .Second )
297+ got2 , err := d .SupportCreate (got .Outputs [0 ].ClaimID , "1.0" , util .PtrToBool (true ), nil , nil )
298+ if err != nil {
299+ t .Error (err )
300+ return
301+ }
302+ prettyPrint (* got2 )
303+
304+ got3 , err := d .SupportList (nil , 1 , 10 )
305+ if err != nil {
306+ t .Error (err )
307+ return
308+ }
309+ found := false
310+ for _ , support := range got3 .Items {
311+ if support .ClaimID == got .Outputs [0 ].ClaimID {
312+ found = true
313+ }
314+ }
315+ if ! found {
316+ t .Error (errors .Err ("support not found" ))
317+ return
318+ }
319+ prettyPrint (* got3 )
320+ got4 , err := d .SupportAbandon (util .PtrToString (got .Outputs [0 ].ClaimID ), nil , nil , nil , nil )
321+ if err != nil {
322+ t .Error (err )
323+ return
324+ }
325+ prettyPrint (* got4 )
326+ }
327+
267328func TestClient_ClaimSearch (t * testing.T ) {
268329 d := NewClient ("" )
269- got , err := d .ClaimSearch (nil , util .PtrToString ("2a8b6d061c5ecb2515f1dd7e04729e9fafac660d" ), nil , nil )
330+ got , err := d .ClaimSearch (nil , util .PtrToString (channelID ), nil , nil )
270331 if err != nil {
271332 t .Error (err )
272333 return
@@ -405,8 +466,7 @@ func TestClient_AccountRemove(t *testing.T) {
405466
406467func TestClient_ChannelExport (t * testing.T ) {
407468 d := NewClient ("" )
408- channelClaimID := "f1ad0d72eae6b471cfd72b7956768c0c191b22d7"
409- response , err := d .ChannelExport (channelClaimID , nil , nil )
469+ response , err := d .ChannelExport (channelID , nil , nil )
410470 if err != nil {
411471 t .Error (err )
412472 }
0 commit comments