From 35fc44f9b98d6970244a517a5a9ca6175a3b40f5 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 12 Aug 2019 15:41:54 +0200 Subject: Rename util function for tests --- test/common.js | 10 +++++----- test/node/blocklist-dht.js | 4 ++-- test/node/blocklist-tracker.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/common.js b/test/common.js index 9ac99a1..8c30686 100644 --- a/test/common.js +++ b/test/common.js @@ -2,12 +2,12 @@ const os = require('os') const fs = require('fs') const path = require('path') -exports.getTestPath = function (infix, infoHash) { - let testPath +exports.getDownloadPath = function (infix, infoHash) { + let downloadPath try { - testPath = path.join(fs.statSync('/tmp') && '/tmp', 'webtorrent', 'test') + downloadPath = path.join(fs.statSync('/tmp') && '/tmp', 'webtorrent', 'test') } catch (err) { - testPath = path.join(typeof os.tmpdir === 'function' ? os.tmpdir() : '/', 'webtorrent', 'test') + downloadPath = path.join(typeof os.tmpdir === 'function' ? os.tmpdir() : '/', 'webtorrent', 'test') } - return path.join(testPath, infix, infoHash) + return path.join(downloadPath, infix, infoHash) } diff --git a/test/node/blocklist-dht.js b/test/node/blocklist-dht.js index d2ce9bc..fa3915a 100644 --- a/test/node/blocklist-dht.js +++ b/test/node/blocklist-dht.js @@ -27,7 +27,7 @@ test('blocklist blocks peers discovered via DHT', function (t) { client1.on('warning', function (err) { t.fail(err) }) var torrent1 = client1.add(fixtures.leaves.parsedTorrent, { - path: common.getTestPath('client_1', fixtures.leaves.parsedTorrent.infoHash) + path: common.getDownloadPath('client_1', fixtures.leaves.parsedTorrent.infoHash) }) torrent1.on('peer', function () { @@ -67,7 +67,7 @@ test('blocklist blocks peers discovered via DHT', function (t) { client2.on('warning', function (err) { t.fail(err) }) var torrent2 = client2.add(fixtures.leaves.parsedTorrent, { - path: common.getTestPath('client_2', fixtures.leaves.parsedTorrent.infoHash) + path: common.getDownloadPath('client_2', fixtures.leaves.parsedTorrent.infoHash) }) torrent2.on('blockedPeer', function (addr) { diff --git a/test/node/blocklist-tracker.js b/test/node/blocklist-tracker.js index 665ad48..e877d24 100644 --- a/test/node/blocklist-tracker.js +++ b/test/node/blocklist-tracker.js @@ -40,7 +40,7 @@ test('blocklist blocks peers discovered via tracker', function (t) { client1.on('warning', function (err) { t.fail(err) }) var torrent1 = client1.add(parsedTorrent, { - path: common.getTestPath('client_1', parsedTorrent.infoHash) + path: common.getDownloadPath('client_1', parsedTorrent.infoHash) }) torrent1.on('invalidPeer', function () { @@ -62,7 +62,7 @@ test('blocklist blocks peers discovered via tracker', function (t) { client2.on('warning', function (err) { t.fail(err) }) var torrent2 = client2.add(parsedTorrent, { - path: common.getTestPath('client_2', parsedTorrent.infoHash) + path: common.getDownloadPath('client_2', parsedTorrent.infoHash) }) torrent2.once('blockedPeer', function () { -- cgit v1.2.3