mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-29 00:41:34 +00:00
chore: run node tests in ci (#1057)
Looks like this project stopped running the `test:node` npm script when it was migrated to gh actions. Re-enable it and fix all the related test failures.
This commit is contained in:
@ -38,13 +38,13 @@ describe('DHT subsystem is configurable', () => {
|
||||
})
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(true)
|
||||
expect(libp2p._dht.isStarted()).to.equal(true)
|
||||
|
||||
await libp2p.stop()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
})
|
||||
|
||||
it('should not start if disabled once libp2p starts', async () => {
|
||||
@ -63,10 +63,10 @@ describe('DHT subsystem is configurable', () => {
|
||||
})
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
})
|
||||
|
||||
it('should allow a manual start', async () => {
|
||||
@ -86,9 +86,9 @@ describe('DHT subsystem is configurable', () => {
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p._dht.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(true)
|
||||
expect(libp2p._dht.isStarted()).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
@ -60,8 +60,8 @@ describe('DHT subsystem operates correctly', () => {
|
||||
expect(connection).to.exist()
|
||||
|
||||
return Promise.all([
|
||||
pWaitFor(() => libp2p._dht.routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht.routingTable.size === 1)
|
||||
pWaitFor(() => libp2p._dht._lan._routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht._lan._routingTable.size === 1)
|
||||
])
|
||||
})
|
||||
|
||||
@ -71,14 +71,14 @@ describe('DHT subsystem operates correctly', () => {
|
||||
|
||||
await libp2p.dialProtocol(remAddr, subsystemMulticodecs)
|
||||
await Promise.all([
|
||||
pWaitFor(() => libp2p._dht.routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht.routingTable.size === 1)
|
||||
pWaitFor(() => libp2p._dht._lan._routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht._lan._routingTable.size === 1)
|
||||
])
|
||||
|
||||
await libp2p.contentRouting.put(key, value)
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
|
||||
expect(fetchedValue).to.eql(value)
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
expect(fetchedValue).to.have.property('val').that.equalBytes(value)
|
||||
})
|
||||
})
|
||||
|
||||
@ -119,11 +119,13 @@ describe('DHT subsystem operates correctly', () => {
|
||||
const connection = await libp2p.dial(remAddr)
|
||||
|
||||
expect(connection).to.exist()
|
||||
expect(libp2p._dht.routingTable.size).to.be.eql(0)
|
||||
expect(remoteLibp2p._dht.routingTable.size).to.be.eql(0)
|
||||
expect(libp2p._dht._lan._routingTable.size).to.be.eql(0)
|
||||
|
||||
await remoteLibp2p._dht.start()
|
||||
return pWaitFor(() => libp2p._dht.routingTable.size === 1)
|
||||
// should be 0 directly after start - TODO this may be susceptible to timing bugs, we should have
|
||||
// the ability to report stats on the DHT routing table instead of reaching into it's heart like this
|
||||
expect(remoteLibp2p._dht._lan._routingTable.size).to.be.eql(0)
|
||||
return pWaitFor(() => libp2p._dht._lan._routingTable.size === 1)
|
||||
})
|
||||
|
||||
it('should put on a peer and get from the other', async () => {
|
||||
@ -133,12 +135,12 @@ describe('DHT subsystem operates correctly', () => {
|
||||
const value = uint8ArrayFromString('world')
|
||||
|
||||
await remoteLibp2p._dht.start()
|
||||
await pWaitFor(() => libp2p._dht.routingTable.size === 1)
|
||||
await pWaitFor(() => libp2p._dht._lan._routingTable.size === 1)
|
||||
|
||||
await libp2p.contentRouting.put(key, value)
|
||||
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
expect(fetchedValue).to.eql(value)
|
||||
expect(fetchedValue).to.have.property('val').that.equalBytes(value)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,7 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const KadDht = require('libp2p-kad-dht')
|
||||
const { multicodec } = require('libp2p-kad-dht')
|
||||
const Crypto = require('../../../src/insecure/plaintext')
|
||||
const Muxer = require('libp2p-mplex')
|
||||
const Transport = require('libp2p-tcp')
|
||||
@ -25,13 +24,12 @@ const subsystemOptions = mergeOptions(baseOptions, {
|
||||
config: {
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: true
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports.subsystemOptions = subsystemOptions
|
||||
module.exports.subsystemMulticodecs = [multicodec]
|
||||
module.exports.subsystemMulticodecs = [
|
||||
'/ipfs/lan/kad/1.0.0'
|
||||
]
|
||||
|
Reference in New Issue
Block a user