Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit af208c3

Browse files
committed
Merge branch 'master' into fix/dns-cache-and-http-throttling-in-browser
License: MIT Signed-off-by: Marcin Rataj <[email protected]>
2 parents e49143e + 502efaf commit af208c3

File tree

6 files changed

+42
-38
lines changed

6 files changed

+42
-38
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"libp2p-delegated-content-routing": "^0.2.4",
129129
"libp2p-delegated-peer-routing": "^0.2.4",
130130
"libp2p-floodsub": "^0.17.2",
131-
"libp2p-gossipsub": "~0.0.4",
131+
"libp2p-gossipsub": "~0.0.5",
132132
"libp2p-kad-dht": "~0.15.3",
133133
"libp2p-keychain": "~0.4.2",
134134
"libp2p-mdns": "~0.12.0",

test/cli/files.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ describe('files', () => runOnAndOff((thing) => {
335335
it('add --only-hash does not add a file to the datastore', function () {
336336
this.timeout(30 * 1000)
337337
this.slow(10 * 1000)
338-
const content = String(Math.random())
338+
const content = hat()
339339
const filepath = path.join(os.tmpdir(), `${content}.txt`)
340340
fs.writeFileSync(filepath, content)
341341

@@ -356,7 +356,7 @@ describe('files', () => runOnAndOff((thing) => {
356356
it('add pins by default', function () {
357357
this.timeout(10 * 1000)
358358
const filePath = path.join(os.tmpdir(), hat())
359-
const content = String(Math.random())
359+
const content = hat()
360360
fs.writeFileSync(filePath, content)
361361

362362
return ipfs(`add -Q ${filePath}`)
@@ -371,7 +371,7 @@ describe('files', () => runOnAndOff((thing) => {
371371
it('add does not pin with --pin=false', function () {
372372
this.timeout(20 * 1000)
373373
const filePath = path.join(os.tmpdir(), hat())
374-
const content = String(Math.random())
374+
const content = hat()
375375
fs.writeFileSync(filePath, content)
376376

377377
return ipfs(`add -Q --pin=false ${filePath}`)

test/cli/object.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-env mocha */
33
'use strict'
44

5+
const hat = require('hat')
56
const expect = require('chai').expect
67
const runOnAndOff = require('../utils/on-and-off')
78
const UnixFs = require('ipfs-unixfs')
@@ -139,7 +140,7 @@ describe('object', () => runOnAndOff((thing) => {
139140

140141
// has to be big enough to span several DAGNodes
141142
const data = crypto.randomBytes(1024 * 300)
142-
const file = path.join(os.tmpdir(), `file-${Math.random()}.txt`)
143+
const file = path.join(os.tmpdir(), `file-${hat()}.txt`)
143144

144145
fs.writeFileSync(file, data)
145146

test/core/bitswap.spec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-env mocha */
33
'use strict'
44

5+
const hat = require('hat')
56
const chai = require('chai')
67
const dirtyChai = require('dirty-chai')
78
const expect = chai.expect
@@ -22,7 +23,7 @@ const callbackify = require('callbackify')
2223
const IPFS = require('../../src/core')
2324

2425
function makeBlock (callback) {
25-
const d = Buffer.from(`IPFS is awesome ${Math.random()}`)
26+
const d = Buffer.from(`IPFS is awesome ${hat()}`)
2627

2728
multihashing(d, 'sha2-256', (err, multihash) => {
2829
if (err) {
@@ -138,7 +139,7 @@ describe('bitswap', function () {
138139

139140
describe('transfer a block between', () => {
140141
it('2 peers', function (done) {
141-
this.timeout(80 * 1000)
142+
this.timeout(160 * 1000)
142143

143144
let remoteNode
144145
let block
@@ -162,7 +163,7 @@ describe('bitswap', function () {
162163
})
163164

164165
it('3 peers', function (done) {
165-
this.timeout(80 * 1000)
166+
this.timeout(160 * 1000)
166167

167168
let blocks
168169
const remoteNodes = []
@@ -214,7 +215,7 @@ describe('bitswap', function () {
214215
it('2 peers', (done) => {
215216
// TODO make this test more interesting (10Mb file)
216217
// TODO remove randomness from the test
217-
const file = Buffer.from(`I love IPFS <3 ${Math.random()}`)
218+
const file = Buffer.from(`I love IPFS <3 ${hat()}`)
218219

219220
waterfall([
220221
// 0. Start node

test/http-api/files.js

+28-27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint max-nested-callbacks: ["error", 8] */
33
'use strict'
44

5+
const hat = require('hat')
56
const chai = require('chai')
67
const dirtyChai = require('dirty-chai')
78
const DaemonFactory = require('ipfsd-ctl')
@@ -34,7 +35,7 @@ describe('.files', () => {
3435

3536
describe('.add', function () {
3637
it('performs a speculative add, --only-hash', () => {
37-
const content = String(Math.random())
38+
const content = hat()
3839

3940
return ipfs.add(Buffer.from(content), { onlyHash: true })
4041
.then(files => {
@@ -60,7 +61,7 @@ describe('.files', () => {
6061
})
6162

6263
it('lists files', () => {
63-
const fileName = `single-file-${Math.random()}.txt`
64+
const fileName = `single-file-${hat()}.txt`
6465

6566
return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {
6667
create: true
@@ -73,8 +74,8 @@ describe('.files', () => {
7374
})
7475

7576
it('lists files in directories', () => {
76-
const dirName = `dir-${Math.random()}`
77-
const fileName = `file-in-dir-${Math.random()}.txt`
77+
const dirName = `dir-${hat()}`
78+
const fileName = `file-in-dir-${hat()}.txt`
7879

7980
return ipfs.files.write(`/${dirName}/${fileName}`, Buffer.from('Hello world'), {
8081
create: true,
@@ -90,8 +91,8 @@ describe('.files', () => {
9091

9192
describe('.cp', function () {
9293
it('copies a file', () => {
93-
const source = `source-file-${Math.random()}.txt`
94-
const destination = `destination-file-${Math.random()}.txt`
94+
const source = `source-file-${hat()}.txt`
95+
const destination = `destination-file-${hat()}.txt`
9596

9697
return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {
9798
create: true
@@ -116,8 +117,8 @@ describe('.files', () => {
116117
})
117118

118119
it('copies a directory', () => {
119-
const source = `source-dir-${Math.random()}`
120-
const destination = `destination-dir-${Math.random()}`
120+
const source = `source-dir-${hat()}`
121+
const destination = `destination-dir-${hat()}`
121122

122123
return ipfs.files.mkdir(`/${source}`)
123124
.then(() => ipfs.files.cp(`/${source}`, `/${destination}`))
@@ -140,8 +141,8 @@ describe('.files', () => {
140141
})
141142

142143
it('copies a file with array args', () => {
143-
const source = `source-file-${Math.random()}.txt`
144-
const destination = `destination-file-${Math.random()}.txt`
144+
const source = `source-file-${hat()}.txt`
145+
const destination = `destination-file-${hat()}.txt`
145146

146147
return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {
147148
create: true
@@ -166,8 +167,8 @@ describe('.files', () => {
166167
})
167168

168169
it('copies a directory with array args', () => {
169-
const source = `source-dir-${Math.random()}`
170-
const destination = `destination-dir-${Math.random()}`
170+
const source = `source-dir-${hat()}`
171+
const destination = `destination-dir-${hat()}`
171172

172173
return ipfs.files.mkdir(`/${source}`)
173174
.then(() => ipfs.files.cp([`/${source}`, `/${destination}`]))
@@ -192,7 +193,7 @@ describe('.files', () => {
192193

193194
describe('.mkdir', function () {
194195
it('makes a directory', () => {
195-
const directory = `directory-${Math.random()}`
196+
const directory = `directory-${hat()}`
196197

197198
return ipfs.files.mkdir(`/${directory}`)
198199
.then(() => ipfs.files.ls(`/`, {
@@ -210,8 +211,8 @@ describe('.files', () => {
210211

211212
describe('.mv', function () {
212213
it('moves a file', () => {
213-
const source = `source-file-${Math.random()}.txt`
214-
const destination = `destination-file-${Math.random()}.txt`
214+
const source = `source-file-${hat()}.txt`
215+
const destination = `destination-file-${hat()}.txt`
215216

216217
return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {
217218
create: true
@@ -234,8 +235,8 @@ describe('.files', () => {
234235
})
235236

236237
it('moves a directory', () => {
237-
const source = `source-dir-${Math.random()}`
238-
const destination = `destination-dir-${Math.random()}`
238+
const source = `source-dir-${hat()}`
239+
const destination = `destination-dir-${hat()}`
239240

240241
return ipfs.files.mkdir(`/${source}`)
241242
.then(() => ipfs.files.mv(`/${source}`, `/${destination}`))
@@ -258,8 +259,8 @@ describe('.files', () => {
258259
})
259260

260261
it('moves a file with array args', () => {
261-
const source = `source-file-${Math.random()}.txt`
262-
const destination = `destination-file-${Math.random()}.txt`
262+
const source = `source-file-${hat()}.txt`
263+
const destination = `destination-file-${hat()}.txt`
263264

264265
return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {
265266
create: true
@@ -282,8 +283,8 @@ describe('.files', () => {
282283
})
283284

284285
it('moves a directory with array args', () => {
285-
const source = `source-dir-${Math.random()}`
286-
const destination = `destination-dir-${Math.random()}`
286+
const source = `source-dir-${hat()}`
287+
const destination = `destination-dir-${hat()}`
287288

288289
return ipfs.files.mkdir(`/${source}`)
289290
.then(() => ipfs.files.mv([`/${source}`, `/${destination}`]))
@@ -308,7 +309,7 @@ describe('.files', () => {
308309

309310
describe('.read', function () {
310311
it('reads a file', () => {
311-
const fileName = `single-file-${Math.random()}.txt`
312+
const fileName = `single-file-${hat()}.txt`
312313
const content = Buffer.from('Hello world')
313314

314315
return ipfs.files.write(`/${fileName}`, content, {
@@ -323,7 +324,7 @@ describe('.files', () => {
323324

324325
describe('.rm', function () {
325326
it('removes a file', () => {
326-
const fileName = `single-file-${Math.random()}.txt`
327+
const fileName = `single-file-${hat()}.txt`
327328

328329
return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {
329330
create: true
@@ -340,8 +341,8 @@ describe('.files', () => {
340341
})
341342

342343
it('removes a directory', () => {
343-
const dirName = `dir-${Math.random()}`
344-
const fileName = `file-in-dir-${Math.random()}.txt`
344+
const dirName = `dir-${hat()}`
345+
const fileName = `file-in-dir-${hat()}.txt`
345346

346347
return ipfs.files.write(`/${dirName}/${fileName}`, Buffer.from('Hello world'), {
347348
create: true,
@@ -363,7 +364,7 @@ describe('.files', () => {
363364

364365
describe('.stat', function () {
365366
it('stats a file', () => {
366-
const fileName = `single-file-${Math.random()}.txt`
367+
const fileName = `single-file-${hat()}.txt`
367368

368369
return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {
369370
create: true
@@ -384,7 +385,7 @@ describe('.files', () => {
384385
})
385386

386387
it('stats a directory', () => {
387-
const dirName = `dir-${Math.random()}`
388+
const dirName = `dir-${hat()}`
388389

389390
return ipfs.files.mkdir(`/${dirName}`)
390391
.then(() => ipfs.files.stat(`/${dirName}`))

test/http-api/inject/dag.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-env mocha */
33
'use strict'
44

5+
const hat = require('hat')
56
const chai = require('chai')
67
const dirtyChai = require('dirty-chai')
78
const expect = chai.expect
@@ -260,7 +261,7 @@ module.exports = (http) => {
260261
it('pins a node after adding', async () => {
261262
const node = {
262263
foo: 'bar',
263-
disambiguator: Math.random()
264+
disambiguator: hat()
264265
}
265266

266267
const res = await api.inject({
@@ -280,7 +281,7 @@ module.exports = (http) => {
280281
it('does not pin a node after adding', async () => {
281282
const node = {
282283
foo: 'bar',
283-
disambiguator: Math.random()
284+
disambiguator: hat()
284285
}
285286

286287
const res = await api.inject({

0 commit comments

Comments
 (0)