This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: report correct swarm addresses after listening on new addrs (#2749)
The user may start the node with no swarm addresses to speed up startup times - if they then use libp2p to listen on new transports we should return the addresses currently being listened on instead of those configured at startup. refs #2508
- Loading branch information
1 parent
cdc7d6b
commit 4a0ffb0
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const { expect } = require('interface-ipfs-core/src/utils/mocha') | ||
const multiaddr = require('multiaddr') | ||
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env') | ||
const factory = require('../utils/factory') | ||
|
||
describe('id', function () { | ||
this.timeout(60 * 1000) | ||
const df = factory() | ||
let node | ||
|
||
before(async () => { | ||
node = (await df.spawn({ | ||
type: 'proc', | ||
ipfsOptions: { | ||
config: { | ||
Addresses: { | ||
Swarm: [] | ||
} | ||
} | ||
} | ||
})).api | ||
}) | ||
|
||
after(async () => { | ||
await node.stop() | ||
}) | ||
|
||
it('should return swarm ports opened after startup', async function () { | ||
if (isWebWorker) { | ||
// TODO: webworkers are not currently dialable | ||
return this.skip() | ||
} | ||
|
||
await expect(node.id()).to.eventually.have.property('addresses').that.is.empty() | ||
|
||
let servers = [ | ||
multiaddr('/ip4/127.0.0.1/tcp/0') | ||
] | ||
|
||
if (isBrowser) { | ||
servers = [ | ||
multiaddr('/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star') | ||
] | ||
} | ||
|
||
await node.libp2p.transportManager.listen(servers) | ||
await expect(node.id()).to.eventually.have.property('addresses').that.is.not.empty() | ||
}) | ||
}) |