Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 25, 2024
1 parent 9fbd889 commit 3f9529c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/libp2p/test/connection-manager/direct.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => {

await expect(libp2p.dial(multiaddr(`/ip4/127.0.0.1/tcp/1234/ws/p2p/${libp2p.peerId.toString()}`)))
.to.eventually.be.rejected()
.and.to.have.property('name', 'DialError')
.and.to.have.property('name', 'InvalidPeerIdError')
})

it('should limit the maximum dial queue size', async () => {
Expand Down
16 changes: 12 additions & 4 deletions packages/libp2p/test/connection-manager/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ describe('Connection Manager', () => {
})
await connectionManager.start()

sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>())
sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>({
remotePeer: peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
}))

// max out the connection limit
await connectionManager.openConnection(peerIdFromPrivateKey(await generateKeyPair('Ed25519')))
Expand Down Expand Up @@ -450,7 +452,9 @@ describe('Connection Manager', () => {
})
await connectionManager.start()

sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>())
sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>({
remotePeer: peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
}))

// max out the connection limit
await connectionManager.openConnection(peerIdFromPrivateKey(await generateKeyPair('Ed25519')))
Expand All @@ -477,7 +481,9 @@ describe('Connection Manager', () => {
})
await connectionManager.start()

sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>())
sinon.stub(connectionManager.dialQueue, 'dial').resolves(stubInterface<Connection>({
remotePeer: peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
}))

// start the upgrade
const maConn1 = mockMultiaddrConnection({
Expand Down Expand Up @@ -525,7 +531,9 @@ describe('Connection Manager', () => {
bytes: 100n
}
})
const newConnection = stubInterface<Connection>()
const newConnection = stubInterface<Connection>({
remotePeer: targetPeer
})

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

0 comments on commit 3f9529c

Please sign in to comment.