Skip to content

Commit

Permalink
test: ensure that libp2p nodes are shutdown in identify service spec
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Jun 1, 2023
1 parent 8e43bb5 commit a78db93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 10 additions & 2 deletions test/identify/service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ describe('identify', () => {

// The connection should have no open streams
await pWaitFor(() => connection.streams.length === 0)

await connection.close()

await libp2p.stop()
})

it('should emit peer:identify event after connecting', async () => {
Expand All @@ -79,11 +82,11 @@ describe('identify', () => {
}))

await libp2p.start()

if (libp2p.services.identify == null) {
throw new Error('Identity service was not configured')
}

const eventPromise = pEvent<'peer:identify', CustomEvent<IdentifyResult>>(libp2p, 'peer:identify')

const connection = await libp2p.dial(remoteAddr)
Expand All @@ -95,7 +98,10 @@ describe('identify', () => {
const remotePeer = peerIdFromString(remoteAddr.getPeerId() ?? '')

expect(event.detail.peerId.equals(remotePeer)).to.be.true()

await connection.close()

await libp2p.stop()
})

it('should store remote agent and protocol versions in metadataBook after connecting', async () => {
Expand Down Expand Up @@ -129,6 +135,8 @@ describe('identify', () => {
const remotePeer = await libp2p.peerStore.get(remotePeerId)
expect(remotePeer.metadata.get('AgentVersion')).to.exist()
expect(remotePeer.metadata.get('ProtocolVersion')).to.exist()

await libp2p.stop()
})

it('should push protocol updates to an already connected peer', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/upgrading/upgrader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,7 @@ describe('libp2p.upgrader', () => {
expect(arg0.stream).to.include.keys(['id', 'recvWindowCapacity', 'sendWindowCapacity', 'sourceInput'])
})

// #TODO Investigate why this is failing https://github.com/libp2p/js-libp2p/issues/1781, skipping for now based https://github.com/libp2p/js-libp2p/pull/1627#issuecomment-1570561645
it.skip('should emit connect and disconnect events', async () => {
it('should emit connect and disconnect events', async () => {
const remotePeer = peers[1]
libp2p = await createLibp2p({
peerId: peers[0],
Expand Down

0 comments on commit a78db93

Please sign in to comment.