Skip to content

Commit

Permalink
chore: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 25, 2024
1 parent 3f9529c commit 57f90a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/libp2p/src/connection-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
}

// make sure we don't already have a connection to this multiaddr
if (conn.id !== connection.id && conn.remoteAddr.equals(connection.remoteAddr)) {
if (options.force !== true && conn.id !== connection.id && conn.remoteAddr.equals(connection.remoteAddr)) {
connection.abort(new InvalidMultiaddrError('Duplicate multiaddr connection'))

// return the existing connection
Expand Down
7 changes: 5 additions & 2 deletions packages/libp2p/test/connection-manager/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,13 @@ describe('Connection Manager', () => {
const existingConnection = stubInterface<Connection>({
limits: {
bytes: 100n
}
},
remotePeer: targetPeer,
remoteAddr: multiaddr(`/ip4/123.123.123.123/tcp/123/p2p-circuit/p2p/${targetPeer}`)
})
const newConnection = stubInterface<Connection>({
remotePeer: targetPeer
remotePeer: targetPeer,
remoteAddr: addr
})

sinon.stub(connectionManager.dialQueue, 'dial')
Expand Down

0 comments on commit 57f90a7

Please sign in to comment.