diff --git a/packages/integration-tests/test/dcutr.node.ts b/packages/integration-tests/test/dcutr.node.ts index 8cca4b3c40..0550428763 100644 --- a/packages/integration-tests/test/dcutr.node.ts +++ b/packages/integration-tests/test/dcutr.node.ts @@ -120,7 +120,7 @@ describe('dcutr', () => { }) }) - // TODO: how to test this? + // TODO: how to test this? We need to simulate a firewall of some sort describe.skip('dctur connection upgrade', () => { beforeEach(async () => { libp2pA = await createLibp2p(createBaseOptions({ @@ -162,7 +162,7 @@ describe('dcutr', () => { } }) - it('should perform connection upgrade', async () => { + it('should perform unilateral connection upgrade', async () => { const relayedAddress = multiaddr(`/ip4/127.0.0.1/tcp/${RELAY_PORT}/p2p/${relay.peerId}/p2p-circuit/p2p/${libp2pB.peerId}`) const connection = await libp2pA.dial(relayedAddress) @@ -175,5 +175,19 @@ describe('dcutr', () => { // should have closed the relayed connection expect(libp2pA.getConnections(libp2pB.peerId)).to.have.lengthOf(1, 'had multiple connections to remote peer') }) + + it('should perform holepunch using TCP Simultaneous Connect', async () => { + const relayedAddress = multiaddr(`/ip4/127.0.0.1/tcp/${RELAY_PORT}/p2p/${relay.peerId}/p2p-circuit/p2p/${libp2pB.peerId}`) + const connection = await libp2pA.dial(relayedAddress) + + // connection should be limited + expect(connection).to.have.property('limits').that.is.ok() + + // wait for DCUtR TCP Simultaneous Connect upgrade + // TODO: implement me + + // should have closed the relayed connection + expect(libp2pA.getConnections(libp2pB.peerId)).to.have.lengthOf(1, 'had multiple connections to remote peer') + }) }) }) diff --git a/packages/interface-internal/src/connection-manager/index.ts b/packages/interface-internal/src/connection-manager/index.ts index adb7ff04b6..d81fe8fd56 100644 --- a/packages/interface-internal/src/connection-manager/index.ts +++ b/packages/interface-internal/src/connection-manager/index.ts @@ -20,6 +20,18 @@ export interface OpenConnectionOptions extends AbortOptions, ProgressOptions