diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index bbfd7ad6..a903aeb7 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -56,8 +56,10 @@ const VERSION_PREFIX = '-WD' + VERSION_STR + '-' /** * Generate an ephemeral peer ID each time. - * TODO: once there are around 2^24 = ~8 million WebTorrent Desktops online at the same time, - * ID collisions will start happening. Birthday paradox. Can we use more than six bytes? + * Once there are around 2^24 = ~8 million WebTorrent Desktops online at the same time, + * ID collisions will start happening. Birthday paradox. + * This is fine, though. Bad peers can already clone someone else's peer ID. + * The network is robust to occasional collisions. */ const PEER_ID = Buffer.from(VERSION_PREFIX + crypto.randomBytes(6).toString('hex')) @@ -166,7 +168,7 @@ function addTorrentEvents (torrent) { function torrentReady () { const info = getTorrentInfo(torrent) ipc.send('wt-ready', torrent.key, info) - ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info) // TODO: hack + ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info) updateTorrentProgress() } diff --git a/test/screenshots/darwin/play-torrent-wired-2.png b/test/screenshots/darwin/play-torrent-wired-2.png index 8b704a5d..af860bc3 100644 Binary files a/test/screenshots/darwin/play-torrent-wired-2.png and b/test/screenshots/darwin/play-torrent-wired-2.png differ diff --git a/test/screenshots/darwin/play-torrent-wired-3.png b/test/screenshots/darwin/play-torrent-wired-3.png index 8ff51d43..f937e62c 100644 Binary files a/test/screenshots/darwin/play-torrent-wired-3.png and b/test/screenshots/darwin/play-torrent-wired-3.png differ diff --git a/test/setup.js b/test/setup.js index af4b962c..5f9e8be1 100644 --- a/test/setup.js +++ b/test/setup.js @@ -165,6 +165,6 @@ function compareTorrentFiles (t, pathActual, pathExpected) { function extractImportantFields (parsedTorrent) { const { infoHash, name, announce, urlList, comment } = parsedTorrent - const priv = parsedTorrent.private + const priv = parsedTorrent.private // private is a reserved word in JS return { infoHash, name, announce, urlList, comment, 'private': priv } } diff --git a/test/test-audio.js b/test/test-audio.js index 558539c5..a7a0f2a2 100644 --- a/test/test-audio.js +++ b/test/test-audio.js @@ -4,7 +4,7 @@ const setup = require('./setup') test('audio-streaming', function (t) { setup.resetTestDataDir() - t.timeoutAfter(40e3) + t.timeoutAfter(60e3) const app = setup.createApp() setup.waitForLoad(app, t, {online: true}) .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) @@ -12,15 +12,17 @@ test('audio-streaming', function (t) { .then(() => app.client.moveToObject('#torrent-wired')) .then(() => setup.wait()) .then(() => app.client.click('#torrent-wired .icon.play')) - .then(() => setup.wait(5e3)) + .then(() => app.client.waitUntilTextExists('The Wired CD')) // Pause. Skip to two seconds in. Wait another two seconds for it to load. .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.wait()) + .then(() => app.client.waitUntilTextExists('Artist')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired')) // Click next .then(() => app.client.click('.skip-next')) - .then(() => setup.wait()) + .then(() => app.client.waitUntilTextExists('The Wired CD')) + .then(() => app.client.moveToObject('.letterbox')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.wait()) @@ -28,7 +30,7 @@ test('audio-streaming', function (t) { // Play from end of song, let it advance on its own .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) - .then(() => setup.wait(5e3)) + .then(() => setup.wait(5e3)) // Let it play a few seconds, past the end of the song .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.wait()) @@ -39,11 +41,11 @@ test('audio-streaming', function (t) { .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-fullscreen')) // Back to normal audio view. Give the player controls have had time to disappear. .then(() => app.webContents.executeJavaScript('dispatch("escapeBack")')) - .then(() => setup.wait(5e3)) + .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-4')) // Back. Return to torrent list .then(() => app.client.click('.back')) - .then(() => setup.wait()) + .then(() => app.client.waitUntilTextExists('Big Buck Bunny')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-list')) // Forward. Should play again where we left off (should not stay paused) .then(() => app.client.click('.forward')) diff --git a/test/test-torrent-list.js b/test/test-torrent-list.js index 7052734c..da0b89a2 100644 --- a/test/test-torrent-list.js +++ b/test/test-torrent-list.js @@ -3,7 +3,7 @@ const fs = require('fs-extra') const setup = require('./setup') const config = require('./config') -test.skip('torrent-list: show download path missing', function (t) { +test('torrent-list: show download path missing', function (t) { setup.resetTestDataDir() fs.removeSync(config.TEST_DIR_DOWNLOAD) @@ -36,7 +36,7 @@ test('torrent-list: start, stop, and delete torrents', function (t) { .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover')) // Click download on the first torrent, start downloading .then(() => app.client.click('.icon.download')) - .then(() => app.client.waitUntilTextExists('.torrent-list', '0%')) + .then(() => app.client.waitUntilTextExists('.torrent-list', '276MB')) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download')) // Click download on the first torrent again, stop downloading .then(() => app.client.click('.icon.download'))