@@ -17,45 +17,46 @@ function testFilterOption (t, serverType) {
1717 }
1818
1919 common . createServer ( t , opts , function ( server , announceUrl ) {
20- var client = new Client ( {
20+ var client1 = new Client ( {
2121 infoHash : fixtures . alice . parsedTorrent . infoHash ,
2222 announce : announceUrl ,
2323 peerId : peerId ,
2424 port : 6881 ,
2525 wrtc : { }
2626 } )
2727
28- client . on ( 'error' , function ( err ) { t . error ( err ) } )
29- if ( serverType === 'ws' ) common . mockWebsocketTracker ( client )
28+ client1 . on ( 'error' , function ( err ) { t . error ( err ) } )
29+ if ( serverType === 'ws' ) common . mockWebsocketTracker ( client1 )
3030
31- client . once ( 'warning' , function ( err ) {
31+ client1 . once ( 'warning' , function ( err ) {
3232 t . ok ( / d i s a l l o w e d i n f o _ h a s h / . test ( err . message ) , 'got client warning' )
3333
34- client . destroy ( function ( ) {
35- t . pass ( 'client destroyed' )
36- client = new Client ( {
34+ client1 . destroy ( function ( ) {
35+ t . pass ( 'client1 destroyed' )
36+
37+ var client2 = new Client ( {
3738 infoHash : fixtures . leaves . parsedTorrent . infoHash ,
3839 announce : announceUrl ,
3940 peerId : peerId ,
4041 port : 6881 ,
4142 wrtc : { }
4243 } )
43- if ( serverType === 'ws' ) common . mockWebsocketTracker ( client )
44+ if ( serverType === 'ws' ) common . mockWebsocketTracker ( client2 )
4445
45- client . on ( 'error' , function ( err ) { t . error ( err ) } )
46- client . on ( 'warning' , function ( err ) { t . error ( err ) } )
46+ client2 . on ( 'error' , function ( err ) { t . error ( err ) } )
47+ client2 . on ( 'warning' , function ( err ) { t . error ( err ) } )
4748
48- client . on ( 'update' , function ( ) {
49+ client2 . on ( 'update' , function ( ) {
4950 t . pass ( 'got announce' )
50- client . destroy ( function ( ) { t . pass ( 'client destroyed' ) } )
51+ client2 . destroy ( function ( ) { t . pass ( 'client2 destroyed' ) } )
5152 server . close ( function ( ) { t . pass ( 'server closed' ) } )
5253 } )
5354
5455 server . on ( 'start' , function ( ) {
5556 t . equal ( Object . keys ( server . torrents ) . length , 1 )
5657 } )
5758
58- client . start ( )
59+ client2 . start ( )
5960 } )
6061 } )
6162
@@ -65,7 +66,7 @@ function testFilterOption (t, serverType) {
6566 t . equal ( Object . keys ( server . torrents ) . length , 0 )
6667 } )
6768
68- client . start ( )
69+ client1 . start ( )
6970 } )
7071}
7172
@@ -93,45 +94,45 @@ function testFilterCustomError (t, serverType) {
9394 }
9495
9596 common . createServer ( t , opts , function ( server , announceUrl ) {
96- var client = new Client ( {
97+ var client1 = new Client ( {
9798 infoHash : fixtures . alice . parsedTorrent . infoHash ,
9899 announce : announceUrl ,
99100 peerId : peerId ,
100101 port : 6881 ,
101102 wrtc : { }
102103 } )
103104
104- client . on ( 'error' , function ( err ) { t . error ( err ) } )
105- if ( serverType === 'ws' ) common . mockWebsocketTracker ( client )
105+ client1 . on ( 'error' , function ( err ) { t . error ( err ) } )
106+ if ( serverType === 'ws' ) common . mockWebsocketTracker ( client1 )
106107
107- client . once ( 'warning' , function ( err ) {
108+ client1 . once ( 'warning' , function ( err ) {
108109 t . ok ( / a l i c e b l o c k e d / . test ( err . message ) , 'got client warning' )
109110
110- client . destroy ( function ( ) {
111- t . pass ( 'client destroyed' )
112- client = new Client ( {
111+ client1 . destroy ( function ( ) {
112+ t . pass ( 'client1 destroyed' )
113+ var client2 = new Client ( {
113114 infoHash : fixtures . leaves . parsedTorrent . infoHash ,
114115 announce : announceUrl ,
115116 peerId : peerId ,
116117 port : 6881 ,
117118 wrtc : { }
118119 } )
119- if ( serverType === 'ws' ) common . mockWebsocketTracker ( client )
120+ if ( serverType === 'ws' ) common . mockWebsocketTracker ( client2 )
120121
121- client . on ( 'error' , function ( err ) { t . error ( err ) } )
122- client . on ( 'warning' , function ( err ) { t . error ( err ) } )
122+ client2 . on ( 'error' , function ( err ) { t . error ( err ) } )
123+ client2 . on ( 'warning' , function ( err ) { t . error ( err ) } )
123124
124- client . on ( 'update' , function ( ) {
125+ client2 . on ( 'update' , function ( ) {
125126 t . pass ( 'got announce' )
126- client . destroy ( function ( ) { t . pass ( 'client destroyed' ) } )
127+ client2 . destroy ( function ( ) { t . pass ( 'client2 destroyed' ) } )
127128 server . close ( function ( ) { t . pass ( 'server closed' ) } )
128129 } )
129130
130131 server . on ( 'start' , function ( ) {
131132 t . equal ( Object . keys ( server . torrents ) . length , 1 )
132133 } )
133134
134- client . start ( )
135+ client2 . start ( )
135136 } )
136137 } )
137138
@@ -141,7 +142,7 @@ function testFilterCustomError (t, serverType) {
141142 t . equal ( Object . keys ( server . torrents ) . length , 0 )
142143 } )
143144
144- client . start ( )
145+ client1 . start ( )
145146 } )
146147}
147148
0 commit comments