mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-18 03:31:22 +00:00
chore: fix lint
test: reduce interval of randomwalk in test chore(test): glob fix
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
"lint": "aegir lint",
|
||||
"build": "aegir build",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"test:node": "aegir test -t node -f test/**/*.node.js test/**/*.spec.js",
|
||||
"test:node": "aegir test -t node -f \"./test/**/*.{node,spec}.js\"",
|
||||
"test:browser": "aegir test -t browser",
|
||||
"release": "aegir release -t node -t browser",
|
||||
"release-minor": "aegir release --type minor -t node -t browser",
|
||||
@ -99,7 +99,7 @@
|
||||
"libp2p-delegated-peer-routing": "^0.4.0",
|
||||
"libp2p-floodsub": "^0.20.0",
|
||||
"libp2p-gossipsub": "^0.2.0",
|
||||
"libp2p-kad-dht": "^0.18.0",
|
||||
"libp2p-kad-dht": "^0.18.2",
|
||||
"libp2p-mdns": "^0.13.0",
|
||||
"libp2p-mplex": "^0.9.1",
|
||||
"libp2p-pnet": "~0.1.0",
|
||||
|
@ -11,18 +11,18 @@ const { AbortError } = require('libp2p-interfaces/src/transport/errors')
|
||||
const AbortController = require('abort-controller')
|
||||
const AggregateError = require('aggregate-error')
|
||||
const pDefer = require('p-defer')
|
||||
const delay = require('delay')
|
||||
|
||||
const { DialRequest } = require('../../src/dialer/dial-request')
|
||||
const createMockConnection = require('../utils/mockConnection')
|
||||
const error = new Error('dial failes')
|
||||
|
||||
describe('Dial Request', () => {
|
||||
it('should end when a single multiaddr dials succeeds', async () => {
|
||||
const mockConnection = await createMockConnection()
|
||||
const actions = {
|
||||
[1]: () => Promise.reject(),
|
||||
[2]: () => Promise.resolve(mockConnection),
|
||||
[3]: () => Promise.reject()
|
||||
1: () => Promise.reject(error),
|
||||
2: () => Promise.resolve(mockConnection),
|
||||
3: () => Promise.reject(error)
|
||||
}
|
||||
const dialAction = (num) => actions[num]()
|
||||
const tokens = ['a', 'b']
|
||||
@ -52,9 +52,9 @@ describe('Dial Request', () => {
|
||||
|
||||
it('should throw an AggregateError if all dials fail', async () => {
|
||||
const actions = {
|
||||
[1]: () => Promise.reject(),
|
||||
[2]: () => Promise.reject(),
|
||||
[3]: () => Promise.reject()
|
||||
1: () => Promise.reject(error),
|
||||
2: () => Promise.reject(error),
|
||||
3: () => Promise.reject(error)
|
||||
}
|
||||
const dialAction = (num) => actions[num]()
|
||||
const addrs = Object.keys(actions)
|
||||
@ -92,7 +92,7 @@ describe('Dial Request', () => {
|
||||
})
|
||||
|
||||
it('should handle a large number of addrs', async () => {
|
||||
const reject = sinon.stub().callsFake(() => Promise.reject())
|
||||
const reject = sinon.stub().callsFake(() => Promise.reject(error))
|
||||
const actions = {}
|
||||
const addrs = [...new Array(25)].map((_, index) => index + 1)
|
||||
addrs.forEach(addr => {
|
||||
@ -138,9 +138,9 @@ describe('Dial Request', () => {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
[1]: deferToAbort,
|
||||
[2]: deferToAbort,
|
||||
[3]: deferToAbort
|
||||
1: deferToAbort,
|
||||
2: deferToAbort,
|
||||
3: deferToAbort
|
||||
}
|
||||
const dialAction = (num, opts) => actions[num](opts)
|
||||
const addrs = Object.keys(actions)
|
||||
|
@ -140,8 +140,8 @@ describe('peer discovery scenarios', () => {
|
||||
dht: {
|
||||
randomWalk: {
|
||||
enabled: true,
|
||||
delay: 100, // start the first query quickly
|
||||
interval: 1000,
|
||||
delay: 1000, // start the first query quickly
|
||||
interval: 10000,
|
||||
timeout: 3000
|
||||
},
|
||||
enabled: true
|
||||
|
Reference in New Issue
Block a user