Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJulen Garcia Leunda <hicom150@gmail.com>2021-07-06 19:51:09 +0300
committerGitHub <noreply@github.com>2021-07-06 19:51:09 +0300
commit100a2aebe23420dd70842b3948896f8fecfee235 (patch)
tree6e651b5a6cd359c83ecaf3a148661b08221ff578 /test
parent149c12d73725c07b86cb3498290f5a6953280559 (diff)
fix: ensure uTP peer address is IPv4 (#2125)
Diffstat (limited to 'test')
-rw-r--r--test/node/conn-pool.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/node/conn-pool.js b/test/node/conn-pool.js
index a4850f2..b77a917 100644
--- a/test/node/conn-pool.js
+++ b/test/node/conn-pool.js
@@ -100,6 +100,54 @@ test('client.conn-pool: use uTP when uTP enabled', function (t) {
})
})
+test('client.conn-pool: adding IPv6 peer when uTP enabled should fallback to TCP', function (t) {
+ t.plan(6)
+
+ const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })
+ const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })
+
+ client1.on('error', function (err) { t.fail(err) })
+ client1.on('warning', function (err) { t.fail(err) })
+
+ client2.on('error', function (err) { t.fail(err) })
+ client2.on('warning', function (err) { t.fail(err) })
+
+ // Start seeding
+ client2.seed(fixtures.leaves.content, {
+ name: 'Leaves of Grass by Walt Whitman.epub',
+ announce: []
+ })
+
+ client2.on('listening', function () {
+ // Start downloading
+ const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })
+
+ // Manually connect peers
+ torrent.addPeer('[::1]:' + client2.address().port)
+
+ let order = 0
+
+ torrent.on('infoHash', function () {
+ t.equal(++order, 1)
+ })
+
+ torrent.on('metadata', function () {
+ t.equal(++order, 2)
+ })
+
+ torrent.on('ready', function () {
+ t.equal(++order, 3)
+ })
+
+ torrent.on('done', function () {
+ t.equal(++order, 4)
+
+ client1.destroy(function (err) { t.error(err, 'client 1 destroyed') })
+ client2.destroy(function (err) { t.error(err, 'client 2 destroyed') })
+ })
+ })
+})
+
// Warning: slow test as we need to rely on connection timeouts
test('client.conn-pool: fallback to TCP when uTP server failed', function (t) {
t.plan(6)