diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-04-21 09:10:32 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-04-21 09:10:32 +0300 |
commit | 3daee2c66cbf752b9e6e49b99492b8c1914a4a58 (patch) | |
tree | fbdd6c10f6a64674268dc77d1b3ccb4a37c44a65 /test/duplicate.js | |
parent | 7a7c4a8b8c49f5c92b7c20ff439bc8614f7d607e (diff) |
BREAKING: Major cleanup
### Added
- `client.listening` property to signal whether TCP server is listening
for incoming
connections.
### Changed
- Merged `Swarm` class into `Torrent` object. Properties on
`torrent.swarm` (like
`torrent.swarm.wires`) now exist on `torrent` (e.g. `torrent.wires`).
- `torrent.addPeer` can no longer be called before the `infoHash` event
has been
emitted.
- Remove `torrent.on('listening')` event. Use `client.on('listening')`
instead.
- Remove support from `TCPPool` for listening on multiple ports. This
was not used by
WebTorrent and just added complexity. There is now a single `TCPPool`
instance for the
whole WebTorrent client.
- Deprecate: Do not use `client.download()` anymore. Use `client.add()`
instead.
- Deprecate: Do not use `torrent.swarm` anymore. Use `torrent` instead.
### Fixed
- When there is a `torrent.on('error')` listener, don't also emit
`client.on('error')`.
- Do not return existing torrent object when duplicate torrent is
added. Fire an
`'error'` event instead.
- Memory leak of `Torrent` object caused by `RarityMap`
- Memory leak of `Torrent` object caused by `TCPPool`
- `client.ratio` and `torrent.ratio` are now calculated as `uploaded /
received` instead
of `uploaded / downloaded`.
Diffstat (limited to 'test/duplicate.js')
-rw-r--r-- | test/duplicate.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/duplicate.js b/test/duplicate.js new file mode 100644 index 0000000..ca06b3d --- /dev/null +++ b/test/duplicate.js @@ -0,0 +1,104 @@ +// var fixtures = require('webtorrent-fixtures') +// var test = require('tape') +// var WebTorrent = require('../') + +// test('client.seed followed by duplicate client.add', function (t) { +// t.plan(6) + +// var client = new WebTorrent({ dht: false, tracker: false }) +// client.on('error', function (err) { t.fail(err) }) +// client.on('warning', function (err) { t.fail(err) }) + +// client.seed(fixtures.leaves.content, { +// name: 'Leaves of Grass by Walt Whitman.epub', +// announce: [] +// }, function (torrent1) { +// t.equal(client.torrents.length, 1) + +// var torrent2 = client.add(torrent1.infoHash) + +// torrent2.once('ready', function () { +// t.fail('torrent ready is not called') +// }) + +// torrent2.once('error', function (err) { +// t.ok(err, 'got expected error on duplicate add') +// t.equal(client.torrents.length, 1) +// t.ok(torrent2.destroyed) +// client.destroy(function (err) { +// t.error(err, 'destroyed client') +// t.equal(client.torrents.length, 0) +// }) +// }) +// }) +// }) + +// TODO +// test('client.seed followed by two duplicate client.add calls', function (t) { +// t.plan(9) + +// var client = new WebTorrent({ dht: false, tracker: false }) +// client.on('error', function (err) { t.fail(err) }) +// client.on('warning', function (err) { t.fail(err) }) + +// client.seed(fixtures.leaves.content, { +// name: 'Leaves of Grass by Walt Whitman.epub', +// announce: [] +// }, function (torrent1) { +// t.equal(client.torrents.length, 1) + +// var torrent2 = client.add(torrent1.infoHash) + +// torrent2.once('ready', function () { +// t.fail('torrent ready is not called') +// }) + +// torrent2.once('error', function (err) { +// t.ok(err, 'got expected error on duplicate add') +// t.equal(client.torrents.length, 1) +// t.ok(torrent2.destroyed) + +// var torrent3 = client.add(torrent1.infoHash) + +// torrent3.once('ready', function () { +// t.fail('torrent ready is not called') +// }) + +// torrent3.once('error', function (err) { +// t.ok(err, 'got expected error on duplicate add') +// t.equal(client.torrents.length, 1) +// t.ok(torrent3.destroyed) +// client.destroy(function (err) { +// t.error(err, 'destroyed client') +// t.equal(client.torrents.length, 0) +// }) +// }) +// }) +// }) +// }) + +// TODO +// test('successive sync client.add, client.remove, client.add, client.remove', function (t) { +// t.plan(3) + +// var client = new WebTorrent({ dht: false, tracker: false }) +// client.on('error', function (err) { t.fail(err) }) +// client.on('warning', function (err) { t.fail(err) }) + +// client.seed(fixtures.leaves.content, { +// name: 'Leaves of Grass by Walt Whitman.epub', +// announce: [] +// }, function (torrent1) { +// t.equal(client.torrents.length, 1) + +// client.add(torrent1.infoHash) +// client.remove(torrent1.infoHash) +// client.add(torrent1.infoHash) +// client.remove(torrent1.infoHash, function () { +// client.destroy(function (err) { +// t.error(err, 'destroyed client') +// t.equal(client.torrents.length, 0) +// }) +// }) +// }) +// }) |