@@ -5,7 +5,7 @@ import { shardInfoToPubsubTopics } from "@waku/utils";
5
5
import chai , { expect } from "chai" ;
6
6
import chaiAsPromised from "chai-as-promised" ;
7
7
8
- import { tearDownNodes } from "../src/index.js" ;
8
+ import { delay , tearDownNodes } from "../src/index.js" ;
9
9
import { makeLogFileName } from "../src/log_file.js" ;
10
10
import { NimGoNode } from "../src/node/node.js" ;
11
11
@@ -117,15 +117,13 @@ describe.only("Metadata Protocol", () => {
117
117
} ) ;
118
118
119
119
const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
120
- const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
121
120
122
121
waku = await createLightNode ( { shardInfo : shardInfo2 } ) ;
123
122
await waku . start ( ) ;
124
123
await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
125
124
126
- await expect (
127
- waku . libp2p . services . metadata ?. query ( nwaku1PeerId )
128
- ) . to . be . rejectedWith ( "the connection is being closed" ) ;
125
+ // add a delay to make sure the connection is closed from the other side
126
+ await delay ( 100 ) ;
129
127
130
128
const activeConnections = waku . libp2p . getConnections ( ) ;
131
129
expect ( activeConnections . length ) . to . equal ( 0 ) ;
@@ -153,15 +151,13 @@ describe.only("Metadata Protocol", () => {
153
151
} ) ;
154
152
155
153
const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
156
- const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
157
154
158
155
waku = await createLightNode ( { shardInfo : shardInfo2 } ) ;
159
156
await waku . start ( ) ;
160
157
await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
161
158
162
- await expect (
163
- waku . libp2p . services . metadata ?. query ( nwaku1PeerId )
164
- ) . to . be . rejectedWith ( "the connection is being closed" ) ;
159
+ // add a delay to make sure the connection is closed from the other side
160
+ await delay ( 100 ) ;
165
161
166
162
const activeConnections = waku . libp2p . getConnections ( ) ;
167
163
expect ( activeConnections . length ) . to . equal ( 0 ) ;
0 commit comments