diff --git a/test/client-large-torrent.js b/test/client-large-torrent.js new file mode 100644 index 0000000..1bf1e05 --- /dev/null +++ b/test/client-large-torrent.js @@ -0,0 +1,32 @@ +var Client = require('../').Client +var fs = require('fs') +var parseTorrent = require('parse-torrent') +var test = require('tape') + +var torrent = fs.readFileSync(__dirname + '/torrents/sintel-5gb.torrent') +var parsedTorrent = parseTorrent(torrent) +var peerId = new Buffer('01234567890123456789') +var port = 6881 + +test('client.start()', function (t) { + t.plan(4) + + var client = new Client(peerId, port, parsedTorrent) + + client.on('error', function (err) { + t.error(err) + }) + + client.once('update', function (data) { + t.equal(data.announce, 'http://t.bitlove.org/announce') + t.equal(typeof data.complete, 'number') + t.equal(typeof data.incomplete, 'number') + }) + + client.once('peer', function (addr) { + t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server! + client.stop() + }) + + client.start() +}) diff --git a/test/torrents/sintel-5gb.torrent b/test/torrents/sintel-5gb.torrent new file mode 100644 index 0000000..65f43c4 Binary files /dev/null and b/test/torrents/sintel-5gb.torrent differ