forked from mafintosh/torrent-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure the torrent event is emitted (mafintosh#189)
* ensure the torrent event is emitted * fix tracker test * remove v4 node as no longer compatible
- Loading branch information
Showing
4 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ node_js: | |
- "node" | ||
- "8" | ||
- "6" | ||
- "4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var test = require('tap').test | ||
var torrents = require('../') | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
var fixture = torrents(fs.readFileSync(path.join(__dirname, 'data', 'star.torrent')), { | ||
dht: false, | ||
tracker: false | ||
}) | ||
fixture.listen(10000) | ||
|
||
var engine = function () { | ||
var e = torrents('magnet:?xt=urn:btih:ef330b39f4801d25b4245212e75a38634bfc856e', { | ||
dht: false, | ||
tracker: false | ||
}) | ||
|
||
e.connect('127.0.0.1:10000') | ||
return e | ||
} | ||
|
||
test('fixture should be ready', function (t) { | ||
t.plan(1) | ||
fixture.on('ready', t.ok.bind(t, true, 'should be ready')) | ||
}) | ||
|
||
test('torrent should be emitted', function (t) { | ||
t.plan(1) | ||
var e = engine() | ||
e.on('torrent', function (torrent) { | ||
t.equal(torrent.infoHash, 'ef330b39f4801d25b4245212e75a38634bfc856e') | ||
e.destroy(t.ok.bind(t, true, 'should be destroyed')) | ||
}) | ||
}) | ||
|
||
test('remove fixture and all content', function (t) { | ||
t.plan(1) | ||
fixture.destroy(function () { | ||
fixture.remove(function () { | ||
t.ok(!fs.existsSync(fixture.path)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters