Skip to content

Commit a78db93

Browse files
committed
test: ensure that libp2p nodes are shutdown in identify service spec
1 parent 8e43bb5 commit a78db93

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/identify/service.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ describe('identify', () => {
6767

6868
// The connection should have no open streams
6969
await pWaitFor(() => connection.streams.length === 0)
70+
7071
await connection.close()
72+
73+
await libp2p.stop()
7174
})
7275

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

8184
await libp2p.start()
82-
85+
8386
if (libp2p.services.identify == null) {
8487
throw new Error('Identity service was not configured')
8588
}
86-
89+
8790
const eventPromise = pEvent<'peer:identify', CustomEvent<IdentifyResult>>(libp2p, 'peer:identify')
8891

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

97100
expect(event.detail.peerId.equals(remotePeer)).to.be.true()
101+
98102
await connection.close()
103+
104+
await libp2p.stop()
99105
})
100106

101107
it('should store remote agent and protocol versions in metadataBook after connecting', async () => {
@@ -129,6 +135,8 @@ describe('identify', () => {
129135
const remotePeer = await libp2p.peerStore.get(remotePeerId)
130136
expect(remotePeer.metadata.get('AgentVersion')).to.exist()
131137
expect(remotePeer.metadata.get('ProtocolVersion')).to.exist()
138+
139+
await libp2p.stop()
132140
})
133141

134142
it('should push protocol updates to an already connected peer', async () => {

test/upgrading/upgrader.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,7 @@ describe('libp2p.upgrader', () => {
668668
expect(arg0.stream).to.include.keys(['id', 'recvWindowCapacity', 'sendWindowCapacity', 'sourceInput'])
669669
})
670670

671-
// #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
672-
it.skip('should emit connect and disconnect events', async () => {
671+
it('should emit connect and disconnect events', async () => {
673672
const remotePeer = peers[1]
674673
libp2p = await createLibp2p({
675674
peerId: peers[0],

0 commit comments

Comments
 (0)