From 96cba10e08d96e30afe6791230d26963ab816f96 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Tue, 5 Dec 2017 10:56:43 +1300 Subject: [PATCH 1/2] test: use os.tmpdir() --- src/swarm.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/swarm.js b/src/swarm.js index 432400f7..49755467 100644 --- a/src/swarm.js +++ b/src/swarm.js @@ -9,6 +9,8 @@ const expect = chai.expect chai.use(dirtyChai) const series = require('async/series') const multiaddr = require('multiaddr') +const os = require('os') +const path = require('path') module.exports = (common) => { describe('.swarm', function () { @@ -125,7 +127,7 @@ module.exports = (common) => { } function getRepoPath () { - return '/tmp/.ipfs-' + Math.random().toString().substring(2, 8) + Date.now() + return path.join(os.tmpdir(), '.ipfs-' + Math.random().toString().substring(2, 8) + Date.now()) } it('Connecting two peers with one address each', (done) => { From ad6e008d5baa488a31be1bcc78f27dc6605879da Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Tue, 5 Dec 2017 20:57:28 +1300 Subject: [PATCH 2/2] test: use hat() for a unique name --- src/swarm.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/swarm.js b/src/swarm.js index 49755467..9c43869a 100644 --- a/src/swarm.js +++ b/src/swarm.js @@ -11,6 +11,7 @@ const series = require('async/series') const multiaddr = require('multiaddr') const os = require('os') const path = require('path') +const hat = require('hat') module.exports = (common) => { describe('.swarm', function () { @@ -127,7 +128,7 @@ module.exports = (common) => { } function getRepoPath () { - return path.join(os.tmpdir(), '.ipfs-' + Math.random().toString().substring(2, 8) + Date.now()) + return path.join(os.tmpdir(), '.ipfs-' + hat()) } it('Connecting two peers with one address each', (done) => {