@@ -12,8 +12,8 @@ parsedTorrent.announce = [ 'udp://tracker.publicbt.com:80' ]
1212var peerId = new Buffer ( '01234567890123456789' )
1313var port = 6881
1414
15- test ( 'udp: client.start()' , function ( t ) {
16- t . plan ( 4 )
15+ test ( 'udp: client.start/update/stop ()' , function ( t ) {
16+ t . plan ( 10 )
1717
1818 var client = new Client ( peerId , port , parsedTorrent )
1919
@@ -29,56 +29,25 @@ test('udp: client.start()', function (t) {
2929
3030 client . once ( 'peer' , function ( addr ) {
3131 t . pass ( 'there is at least one peer' ) // TODO: this shouldn't rely on an external server!
32- client . stop ( )
33- } )
34-
35- client . start ( )
36- } )
37-
38- test ( 'udp: client.stop()' , function ( t ) {
39- t . plan ( 3 )
40-
41- var client = new Client ( peerId , port , parsedTorrent )
42-
43- client . on ( 'error' , function ( err ) {
44- t . error ( err )
45- } )
46-
47- client . start ( )
48-
49- setTimeout ( function ( ) {
50- client . stop ( )
5132
5233 client . once ( 'update' , function ( data ) {
5334 // receive one final update after calling stop
5435 t . equal ( data . announce , 'udp://tracker.publicbt.com:80' )
5536 t . equal ( typeof data . complete , 'number' )
5637 t . equal ( typeof data . incomplete , 'number' )
57- } )
5838
59- } , 1000 )
60- } )
39+ client . once ( 'update' , function ( data ) {
40+ // received an update!
41+ t . equal ( data . announce , 'udp://tracker.publicbt.com:80' )
42+ t . equal ( typeof data . complete , 'number' )
43+ t . equal ( typeof data . incomplete , 'number' )
44+ } )
6145
62- test ( 'udp: client.update()' , function ( t ) {
63- t . plan ( 3 )
64-
65- var client = new Client ( peerId , port , parsedTorrent , { interval : 5000 } )
66-
67- client . on ( 'error' , function ( err ) {
68- t . error ( err )
69- } )
70-
71- client . start ( )
72-
73- client . once ( 'update' , function ( ) {
74-
75- client . once ( 'update' , function ( data ) {
76- // received an update!
77- t . equal ( data . announce , 'udp://tracker.publicbt.com:80' )
78- t . equal ( typeof data . complete , 'number' )
79- t . equal ( typeof data . incomplete , 'number' )
8046 client . stop ( )
8147 } )
8248
49+ client . update ( )
8350 } )
51+
52+ client . start ( )
8453} )
0 commit comments