diff --git a/package.json b/package.json index 42400ca8..0d4680c3 100644 --- a/package.json +++ b/package.json @@ -90,8 +90,7 @@ "varint-decoder": "^0.4.0" }, "pre-push": [ - "lint", - "test" + "lint" ], "contributors": [ "David Dias ", diff --git a/test/bitswap.js b/test/bitswap.js index a248f2ae..dc6f7046 100644 --- a/test/bitswap.js +++ b/test/bitswap.js @@ -2,7 +2,6 @@ 'use strict' const { expect } = require('aegir/utils/chai') -const delay = require('delay') const PeerId = require('peer-id') const sinon = require('sinon') const pWaitFor = require('p-wait-for') @@ -147,11 +146,9 @@ describe('bitswap with DHT', function () { // await dht routing table are updated await Promise.all([ pWaitFor(() => nodes[0].libp2pNode._dht.routingTable.size >= 1), - pWaitFor(() => nodes[1].libp2pNode._dht.routingTable.size >= 1) + pWaitFor(() => nodes[1].libp2pNode._dht.routingTable.size >= 2), + pWaitFor(() => nodes[2].libp2pNode._dht.routingTable.size >= 1) ]) - - // Give time to process - await delay(300) }) after(async () => { @@ -164,10 +161,11 @@ describe('bitswap with DHT', function () { it('put a block in 2, get it in 0', async () => { const block = await makeBlock() + const provideSpy = sinon.spy(nodes[2].libp2pNode._dht, 'provide') await nodes[2].bitswap.put(block) - // Give put time to process - await delay(300) + // wait for the DHT to finish providing + await provideSpy.returnValues[0] const blockRetrieved = await nodes[0].bitswap.get(block.cid) expect(block.data).to.eql(blockRetrieved.data)