@@ -3,6 +3,7 @@ package jsonrpc
33import (
44 "encoding/json"
55 "fmt"
6+ "os"
67 "strconv"
78 "strings"
89 "testing"
@@ -23,19 +24,23 @@ func TestClient_AccountFund(t *testing.T) {
2324 accounts , err := d .AccountList ()
2425 if err != nil {
2526 t .Error (err )
27+ return
2628 }
2729 account := (accounts .LBCRegtest )[0 ].ID
2830 balanceString , err := d .AccountBalance (& account )
2931 if err != nil {
3032 t .Error (err )
33+ return
3134 }
3235 balance , err := strconv .ParseFloat (string (* balanceString ), 64 )
3336 if err != nil {
3437 t .Error (err )
38+ return
3539 }
3640 got , err := d .AccountFund (account , account , fmt .Sprintf ("%f" , balance / 2.0 ), 40 )
3741 if err != nil {
3842 t .Error (err )
43+ return
3944 }
4045 prettyPrint (* got )
4146}
@@ -45,6 +50,7 @@ func TestClient_AccountList(t *testing.T) {
4550 got , err := d .AccountList ()
4651 if err != nil {
4752 t .Error (err )
53+ return
4854 }
4955 prettyPrint (* got )
5056}
@@ -54,10 +60,12 @@ func TestClient_SingleAccountList(t *testing.T) {
5460 createdAccount , err := d .AccountCreate ("test" + fmt .Sprintf ("%d" , time .Now ().Unix ())+ "@lbry.com" , false )
5561 if err != nil {
5662 t .Fatal (err )
63+ return
5764 }
5865 account , err := d .SingleAccountList (createdAccount .ID )
5966 if err != nil {
6067 t .Fatal (err )
68+ return
6169 }
6270 prettyPrint (* account )
6371}
@@ -67,6 +75,7 @@ func TestClient_AccountBalance(t *testing.T) {
6775 got , err := d .AccountBalance (nil )
6876 if err != nil {
6977 t .Error (err )
78+ return
7079 }
7180 prettyPrint (* got )
7281}
@@ -76,6 +85,7 @@ func TestClient_AddressUnused(t *testing.T) {
7685 got , err := d .AddressUnused (nil )
7786 if err != nil {
7887 t .Error (err )
88+ return
7989 }
8090 prettyPrint (* got )
8191}
@@ -85,18 +95,21 @@ func TestClient_ChannelList(t *testing.T) {
8595 got , err := d .ChannelList (nil , 1 , 50 )
8696 if err != nil {
8797 t .Error (err )
98+ return
8899 }
89100 prettyPrint (* got )
90101}
91102
92103func TestClient_StreamCreate (t * testing.T ) {
104+ _ = os .Setenv ("BLOCKCHAIN_NAME" , "lbrycrd_regtest" )
93105 d := NewClient ("" )
94106 addressResponse , err := d .AddressUnused (nil )
95107 if err != nil {
96108 t .Error (err )
109+ return
97110 }
98111 address := string (* addressResponse )
99- got , err := d .StreamCreate ("test" + fmt .Sprintf ("%d" , time .Now ().Unix ()), "/home/niko/work2/2019-04-11_17-36-25-925698088.png " , 14.37 , StreamCreateOptions {
112+ got , err := d .StreamCreate ("test" + fmt .Sprintf ("%d" , time .Now ().Unix ()), "/home/niko/Downloads/IMG_20171012_205120.jpg " , 14.37 , StreamCreateOptions {
100113 ClaimCreateOptions : ClaimCreateOptions {
101114 Title : "This is a Test Title" + fmt .Sprintf ("%d" , time .Now ().Unix ()),
102115 Description : "My Special Description" ,
@@ -129,11 +142,12 @@ func TestClient_StreamCreate(t *testing.T) {
129142 Preview : nil ,
130143 AllowDuplicateName : nil ,
131144 ChannelName : nil ,
132- ChannelID : util .PtrToString ("2e28aa6dbd41f959893907841f4e40d0ecb0ede9 " ),
145+ ChannelID : util .PtrToString ("253ca42da47ad8a430e18d52860cb499c50eff25 " ),
133146 ChannelAccountID : nil ,
134147 })
135148 if err != nil {
136149 t .Error (err )
150+ return
137151 }
138152 prettyPrint (* got )
139153}
@@ -159,13 +173,14 @@ func TestClient_ChannelCreate(t *testing.T) {
159173 })
160174 if err != nil {
161175 t .Error (err )
176+ return
162177 }
163178 prettyPrint (* got )
164179}
165180
166181func TestClient_ChannelUpdate (t * testing.T ) {
167182 d := NewClient ("" )
168- got , err := d .ChannelUpdate ("709868122fe3560a3929d6d63bdbc792d8306a6c " , ChannelUpdateOptions {
183+ got , err := d .ChannelUpdate ("2a8b6d061c5ecb2515f1dd7e04729e9fafac660d " , ChannelUpdateOptions {
169184 ClearLanguages : util .PtrToBool (true ),
170185 ClearLocations : util .PtrToBool (true ),
171186 ClearTags : util .PtrToBool (true ),
@@ -188,6 +203,7 @@ func TestClient_ChannelUpdate(t *testing.T) {
188203 }})
189204 if err != nil {
190205 t .Error (err )
206+ return
191207 }
192208 prettyPrint (* got )
193209}
@@ -214,13 +230,15 @@ func TestClient_ChannelAbandon(t *testing.T) {
214230 })
215231 if err != nil {
216232 t .Error (err )
233+ return
217234 }
218235 txID := channelResponse .Outputs [0 ].Txid
219236 nout := channelResponse .Outputs [0 ].Nout
220237 time .Sleep (10 * time .Second )
221238 got , err := d .ChannelAbandon (txID , nout , nil , false )
222239 if err != nil {
223240 t .Error (err )
241+ return
224242 }
225243 prettyPrint (* got )
226244}
@@ -230,24 +248,28 @@ func TestClient_AddressList(t *testing.T) {
230248 got , err := d .AddressList (nil )
231249 if err != nil {
232250 t .Error (err )
251+ return
233252 }
234253 prettyPrint (* got )
235254}
236255
237256func TestClient_ClaimList (t * testing.T ) {
257+ _ = os .Setenv ("BLOCKCHAIN_NAME" , "lbrycrd_regtest" )
238258 d := NewClient ("" )
239259 got , err := d .ClaimList (nil , 1 , 10 )
240260 if err != nil {
241261 t .Error (err )
262+ return
242263 }
243264 prettyPrint (* got )
244265}
245266
246267func TestClient_ClaimSearch (t * testing.T ) {
247268 d := NewClient ("" )
248- got , err := d .ClaimSearch (nil , util .PtrToString ("1b2b530dfcef9885354f8f41190c8f678da5414e " ), nil , nil )
269+ got , err := d .ClaimSearch (nil , util .PtrToString ("2a8b6d061c5ecb2515f1dd7e04729e9fafac660d " ), nil , nil )
249270 if err != nil {
250271 t .Error (err )
272+ return
251273 }
252274 prettyPrint (* got )
253275}
@@ -257,6 +279,7 @@ func TestClient_Status(t *testing.T) {
257279 got , err := d .Status ()
258280 if err != nil {
259281 t .Error (err )
282+ return
260283 }
261284 prettyPrint (* got )
262285}
@@ -266,6 +289,7 @@ func TestClient_UTXOList(t *testing.T) {
266289 got , err := d .UTXOList (nil )
267290 if err != nil {
268291 t .Error (err )
292+ return
269293 }
270294 prettyPrint (* got )
271295}
@@ -275,36 +299,42 @@ func TestClient_Version(t *testing.T) {
275299 got , err := d .Version ()
276300 if err != nil {
277301 t .Error (err )
302+ return
278303 }
279304 prettyPrint (* got )
280305}
281306
282307func TestClient_GetFile (t * testing.T ) {
283308 d := NewClient ("" )
284- got , err := d .Get ("lbry://test1555965264 " )
309+ got , err := d .Get ("lbry://test1559058649 " )
285310 if err != nil {
286311 t .Error (err )
312+ return
287313 }
288314 prettyPrint (* got )
289315}
290316
291317func TestClient_FileList (t * testing.T ) {
318+ _ = os .Setenv ("BLOCKCHAIN_NAME" , "lbrycrd_regtest" )
292319 d := NewClient ("" )
293320 got , err := d .FileList ()
294321 if err != nil {
295322 t .Error (err )
323+ return
296324 }
297325 prettyPrint (* got )
298326}
299327
300328func TestClient_Resolve (t * testing.T ) {
301329 d := NewClient ("" )
302- got , err := d .Resolve ("test1555965264 " )
330+ got , err := d .Resolve ("test1559058649 " )
303331 if err != nil {
304332 t .Error (err )
333+ return
305334 }
306335 if err != nil {
307336 t .Error (err )
337+ return
308338 }
309339 prettyPrint (* got )
310340}
@@ -314,12 +344,14 @@ func TestClient_AccountSet(t *testing.T) {
314344 accounts , err := d .AccountList ()
315345 if err != nil {
316346 t .Error (err )
347+ return
317348 }
318349 account := (accounts .LBCRegtest )[0 ].ID
319350
320351 got , err := d .AccountSet (account , AccountSettings {ChangeMaxUses : 10000 })
321352 if err != nil {
322353 t .Error (err )
354+ return
323355 }
324356 prettyPrint (* got )
325357}
@@ -330,9 +362,11 @@ func TestClient_AccountCreate(t *testing.T) {
330362 account , err := d .AccountCreate (name , false )
331363 if err != nil {
332364 t .Fatal (err )
365+ return
333366 }
334367 if account .Name != name {
335368 t .Errorf ("account name mismatch, expected %q, got %q" , name , account .Name )
369+ return
336370 }
337371 prettyPrint (* account )
338372}
@@ -342,19 +376,27 @@ func TestClient_AccountRemove(t *testing.T) {
342376 createdAccount , err := d .AccountCreate ("test" + fmt .Sprintf ("%d" , time .Now ().Unix ())+ "@lbry.com" , false )
343377 if err != nil {
344378 t .Fatal (err )
379+ return
345380 }
346381 removedAccount , err := d .AccountRemove (createdAccount .ID )
347382 if err != nil {
348383 t .Error (err )
384+ return
349385 }
350386 if removedAccount .ID != createdAccount .ID {
351387 t .Error ("accounts IDs mismatch" )
352388 }
353389
354390 account , err := d .SingleAccountList (createdAccount .ID )
355- if ! strings .HasPrefix (err .Error (), "Error in daemon: Couldn't find account" ) {
356- t .Error ("account was not removed" )
391+ if err != nil {
392+ if strings .HasPrefix (err .Error (), "Error in daemon: Couldn't find account" ) {
393+ prettyPrint (* removedAccount )
394+ return
395+ }
396+
397+ t .Error (err )
398+ return
357399 }
358- fmt . Println ( err . Error () )
400+ t . Error ("account was not removed" )
359401 prettyPrint (* account )
360402}
0 commit comments