mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 19:06:27 +00:00
try to make wrtc test reliable on node v5
This commit is contained in:
parent
2376fe6f41
commit
0b7edf84a7
@ -1,14 +1,19 @@
|
||||
var Client = require('../')
|
||||
var common = require('./common')
|
||||
var test = require('tape')
|
||||
var wrtc
|
||||
var wrtc = require('electron-webrtc')()
|
||||
|
||||
var wrtcReady = false
|
||||
wrtc.electronDaemon.once('ready', function () {
|
||||
wrtcReady = true
|
||||
})
|
||||
|
||||
var infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705'
|
||||
var peerId = new Buffer('01234567890123456789')
|
||||
var peerId2 = new Buffer('12345678901234567890')
|
||||
var torrentLength = 50000
|
||||
|
||||
function serverTest (t, serverType, serverFamily, cb) {
|
||||
function serverTest (t, serverType, serverFamily) {
|
||||
t.plan(30)
|
||||
|
||||
var hostname = serverFamily === 'inet6'
|
||||
@ -107,7 +112,8 @@ function serverTest (t, serverType, serverFamily, cb) {
|
||||
t.equal(data.incomplete, 0)
|
||||
|
||||
client1.destroy()
|
||||
server.close(cb)
|
||||
server.close()
|
||||
if (serverType === 'ws') wrtc.close()
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -119,12 +125,14 @@ function serverTest (t, serverType, serverFamily, cb) {
|
||||
}
|
||||
|
||||
test('websocket server', function (t) {
|
||||
wrtc = require('electron-webrtc')()
|
||||
wrtc.electronDaemon.once('ready', function () {
|
||||
serverTest(t, 'ws', 'inet', function () {
|
||||
wrtc.close()
|
||||
})
|
||||
})
|
||||
if (wrtcReady) {
|
||||
runTest()
|
||||
} else {
|
||||
wrtc.electronDaemon.once('ready', runTest)
|
||||
}
|
||||
function runTest () {
|
||||
serverTest(t, 'ws', 'inet')
|
||||
}
|
||||
})
|
||||
|
||||
test('http ipv4 server', function (t) {
|
||||
|
Loading…
Reference in New Issue
Block a user