|
|
@ -125,6 +125,38 @@ tape('timeouts', async function (t) { |
|
|
|
b.destroy() |
|
|
|
}) |
|
|
|
|
|
|
|
tape('request with/without retries', async function (t) { |
|
|
|
const [bootstrap, a, b] = await makeSwarm(3) |
|
|
|
let tries = 0 |
|
|
|
|
|
|
|
b.on('request', function (req) { |
|
|
|
if (req.command === 'nope') { |
|
|
|
tries++ |
|
|
|
t.pass('ignoring request') |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
try { |
|
|
|
await a.request({ command: 'nope', target: Buffer.alloc(32) }, { host: '127.0.0.1', port: b.address().port }) |
|
|
|
} catch { |
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
|
|
|
|
t.same(tries, 3) |
|
|
|
|
|
|
|
try { |
|
|
|
await a.request({ command: 'nope', target: Buffer.alloc(32) }, { host: '127.0.0.1', port: b.address().port }, { retry: false }) |
|
|
|
} catch { |
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
|
|
|
|
t.same(tries, 4) |
|
|
|
|
|
|
|
bootstrap.destroy() |
|
|
|
a.destroy() |
|
|
|
b.destroy() |
|
|
|
}) |
|
|
|
|
|
|
|
tape('shorthand commit', async function (t) { |
|
|
|
const swarm = await makeSwarm(40) |
|
|
|
|
|
|
|