Skip to content

Commit

Permalink
fix: really remove node globals (#219)
Browse files Browse the repository at this point in the history
* fix: really remove node globals

* fix: fix scheduleProcessTasks

* fix: bump varint

* fix: bump varint
  • Loading branch information
hugomrdias committed Apr 27, 2020
1 parent 6a4e512 commit 120d1c7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@
"aegir": "^21.9.0",
"async-iterator-all": "^1.0.0",
"benchmark": "^2.1.4",
"buffer": "^5.6.0",
"chai": "^4.2.0",
"delay": "^4.3.0",
"dirty-chai": "^2.0.1",
"ipfs-repo": "^2.0.0",
"ipfs-utils": "^2.2.0",
"iso-random-stream": "^1.1.1",
"libp2p": "^0.27.0",
"libp2p-kad-dht": "^0.18.3",
"libp2p-mplex": "^0.9.2",
Expand All @@ -68,7 +71,6 @@
"peer-info": "^0.17.0",
"promisify-es6": "^1.0.3",
"rimraf": "^3.0.0",
"buffer": "^5.6.0",
"stats-lite": "^2.2.0",
"uuid": "^3.3.2"
},
Expand All @@ -85,7 +87,7 @@
"multihashing-async": "^0.8.0",
"protons": "^1.0.1",
"streaming-iterables": "^4.1.1",
"varint-decoder": "~0.1.1"
"varint-decoder": "^0.4.0"
},
"pre-push": [
"lint",
Expand Down
4 changes: 3 additions & 1 deletion src/decision-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class DecisionEngine {
}

_scheduleProcessTasks () {
setImmediate(() => this._processTasks())
setTimeout(() => {
this._processTasks()
})
}

// Pull tasks off the request queue and send a message to the corresponding
Expand Down
4 changes: 2 additions & 2 deletions test/utils/make-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
const multihashing = require('multihashing-async')
const CID = require('cids')
const Block = require('ipld-block')
const crypto = require('crypto')
const randomBytes = require('iso-random-stream/src/random')
const range = require('lodash.range')
const { Buffer } = require('buffer')
const uuid = require('uuid/v4')

module.exports = async (count, size) => {
const blocks = await Promise.all(
range(count || 1).map(async () => {
const data = size ? crypto.randomBytes(size) : Buffer.from(`hello world ${uuid()}`)
const data = size ? randomBytes(size) : Buffer.from(`hello world ${uuid()}`)
const hash = await multihashing(data, 'sha2-256')
return new Block(data, new CID(hash))
})
Expand Down
8 changes: 4 additions & 4 deletions test/utils/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const PeerStore = require('libp2p/src/peer-store')
const Node = require('./create-libp2p-node').bundle
const os = require('os')
const tmpdir = require('ipfs-utils/src/temp-dir')
const Repo = require('ipfs-repo')
const EventEmitter = require('events')

Expand Down Expand Up @@ -59,14 +59,14 @@ exports.mockNetwork = (calls, done, onMsg) => {
messages,
connects,
connectTo (p) {
setImmediate(() => {
setTimeout(() => {
connects.push(p)
})
},
sendMessage (p, msg) {
messages.push([p, msg])

setImmediate(() => {
setTimeout(() => {
finish([p, msg])
})

Expand Down Expand Up @@ -182,7 +182,7 @@ exports.genBitswapNetwork = async (n, enableDHT = false) => {
})

// create the repos
const tmpDir = os.tmpdir()
const tmpDir = tmpdir()
netArray.forEach((net, i) => {
const repoPath = tmpDir + '/' + net.peerInfo.id.toB58String()
net.repo = new Repo(repoPath)
Expand Down

0 comments on commit 120d1c7

Please sign in to comment.