@@ -12,7 +12,11 @@ function testFilterOption (t, serverType) {
1212 var opts = { serverType : serverType } // this is test-suite-only option
1313 opts . filter = function ( infoHash , params , cb ) {
1414 process . nextTick ( function ( ) {
15- cb ( infoHash !== fixtures . alice . parsedTorrent . infoHash )
15+ if ( infoHash === fixtures . alice . parsedTorrent . infoHash ) {
16+ cb ( new Error ( 'disallowed info_hash (Alice)' ) )
17+ } else {
18+ cb ( null )
19+ }
1620 } )
1721 }
1822
@@ -29,7 +33,7 @@ function testFilterOption (t, serverType) {
2933 if ( serverType === 'ws' ) common . mockWebsocketTracker ( client1 )
3034
3135 client1 . once ( 'warning' , function ( err ) {
32- 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' )
36+ t . ok ( err . message . includes ( ' disallowed info_hash (Alice)' ) , 'got client warning' )
3337
3438 client1 . destroy ( function ( ) {
3539 t . pass ( 'client1 destroyed' )
@@ -62,7 +66,7 @@ function testFilterOption (t, serverType) {
6266
6367 server . removeAllListeners ( 'warning' )
6468 server . once ( 'warning' , function ( err ) {
65- t . ok ( / d i s a l l o w e d i n f o _ h a s h / . test ( err . message ) , 'got server warning' )
69+ t . ok ( err . message . includes ( ' disallowed info_hash (Alice)' ) , 'got server warning' )
6670 t . equal ( Object . keys ( server . torrents ) . length , 0 )
6771 } )
6872
@@ -88,8 +92,11 @@ function testFilterCustomError (t, serverType) {
8892 var opts = { serverType : serverType } // this is test-suite-only option
8993 opts . filter = function ( infoHash , params , cb ) {
9094 process . nextTick ( function ( ) {
91- if ( infoHash === fixtures . alice . parsedTorrent . infoHash ) cb ( new Error ( 'alice blocked' ) )
92- else cb ( true )
95+ if ( infoHash === fixtures . alice . parsedTorrent . infoHash ) {
96+ cb ( new Error ( 'alice blocked' ) )
97+ } else {
98+ cb ( null )
99+ }
93100 } )
94101 }
95102
0 commit comments