11import { MetadataCodec } from "@waku/core" ;
22import type { LightNode } from "@waku/interfaces" ;
3- import { createLightNode } from "@waku/sdk" ;
43import { decodeRelayShard } from "@waku/utils" ;
54import chai , { expect } from "chai" ;
65import chaiAsPromised from "chai-as-promised" ;
76
87import {
98 afterEachCustom ,
10- beforeEachCustom ,
119 delay ,
12- makeLogFileName ,
1310 ServiceNode ,
11+ startLightNode ,
12+ startServiceNode ,
1413 tearDownNodes
1514} from "../src/index.js" ;
1615
@@ -21,10 +20,6 @@ describe("Metadata Protocol", function () {
2120 let waku : LightNode ;
2221 let nwaku1 : ServiceNode ;
2322
24- beforeEachCustom ( this , async ( ) => {
25- nwaku1 = new ServiceNode ( makeLogFileName ( this . ctx ) + "1" ) ;
26- } ) ;
27-
2823 afterEachCustom ( this , async ( ) => {
2924 await tearDownNodes ( [ nwaku1 ] , waku ) ;
3025 } ) ;
@@ -35,7 +30,7 @@ describe("Metadata Protocol", function () {
3530 const shards = [ 1 ] ;
3631 const numShardsInCluster = 8 ;
3732
38- await nwaku1 . start ( {
33+ nwaku1 = await startServiceNode ( this , {
3934 relay : true ,
4035 discv5Discovery : true ,
4136 peerExchange : true ,
@@ -47,10 +42,9 @@ describe("Metadata Protocol", function () {
4742 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
4843 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
4944
50- waku = await createLightNode ( {
45+ waku = await startLightNode ( {
5146 networkConfig : { clusterId, numShardsInCluster }
5247 } ) ;
53- await waku . start ( ) ;
5448 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
5549
5650 if ( ! waku . libp2p . services . metadata ) {
@@ -80,7 +74,7 @@ describe("Metadata Protocol", function () {
8074 const shards = [ 1 ] ;
8175 const numShardsInCluster = 8 ;
8276
83- await nwaku1 . start ( {
77+ nwaku1 = await startServiceNode ( this , {
8478 relay : true ,
8579 discv5Discovery : true ,
8680 peerExchange : true ,
@@ -91,10 +85,9 @@ describe("Metadata Protocol", function () {
9185
9286 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
9387
94- waku = await createLightNode ( {
88+ waku = await startLightNode ( {
9589 networkConfig : { clusterId : custerIdJsWaku , numShardsInCluster }
9690 } ) ;
97- await waku . start ( ) ;
9891 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
9992
10093 // ensure the connection is closed from the other side
@@ -115,7 +108,7 @@ describe("Metadata Protocol", function () {
115108 const shards = [ 1 ] ;
116109 const numShardsInCluster = 8 ;
117110
118- await nwaku1 . start ( {
111+ nwaku1 = await startServiceNode ( this , {
119112 relay : true ,
120113 discv5Discovery : true ,
121114 peerExchange : true ,
@@ -127,10 +120,9 @@ describe("Metadata Protocol", function () {
127120 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
128121 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
129122
130- waku = await createLightNode ( {
123+ waku = await startLightNode ( {
131124 networkConfig : { clusterId, numShardsInCluster }
132125 } ) ;
133- await waku . start ( ) ;
134126 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
135127
136128 // delay to ensure the connection is estabilished and shardInfo is updated
@@ -153,7 +145,7 @@ describe("Metadata Protocol", function () {
153145 const shards = [ 1 ] ;
154146 const numShardsInCluster = 0 ; //static sharding
155147
156- await nwaku1 . start ( {
148+ nwaku1 = await startServiceNode ( this , {
157149 relay : true ,
158150 discv5Discovery : true ,
159151 peerExchange : true ,
@@ -165,7 +157,7 @@ describe("Metadata Protocol", function () {
165157 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
166158 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
167159
168- waku = await createLightNode ( {
160+ waku = await startLightNode ( {
169161 networkConfig : {
170162 clusterId,
171163 numShardsInCluster
@@ -174,7 +166,6 @@ describe("Metadata Protocol", function () {
174166 pingKeepAlive : 1
175167 }
176168 } ) ;
177- await waku . start ( ) ;
178169 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
179170
180171 // delay to ensure the connection is estabilished, shardInfo is updated, and there is a ping
@@ -193,7 +184,7 @@ describe("Metadata Protocol", function () {
193184 const contentTopic = "/foo/1/bar/proto" ;
194185 const numShardsInCluster = 0 ;
195186
196- await nwaku1 . start ( {
187+ nwaku1 = await startServiceNode ( this , {
197188 relay : true ,
198189 discv5Discovery : true ,
199190 peerExchange : true ,
@@ -205,10 +196,9 @@ describe("Metadata Protocol", function () {
205196 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
206197 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
207198
208- waku = await createLightNode ( {
199+ waku = await startLightNode ( {
209200 networkConfig : { clusterId, numShardsInCluster }
210201 } ) ;
211- await waku . start ( ) ;
212202 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
213203
214204 if ( ! waku . libp2p . services . metadata ) {
@@ -239,7 +229,7 @@ describe("Metadata Protocol", function () {
239229 const contentTopic = [ "/foo/1/bar/proto" ] ;
240230 const numShardsInCluster = 0 ;
241231
242- await nwaku1 . start ( {
232+ nwaku1 = await startServiceNode ( this , {
243233 relay : true ,
244234 discv5Discovery : true ,
245235 peerExchange : true ,
@@ -250,13 +240,12 @@ describe("Metadata Protocol", function () {
250240
251241 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
252242
253- waku = await createLightNode ( {
243+ waku = await startLightNode ( {
254244 networkConfig : {
255245 clusterId : clusterIdJSWaku ,
256246 numShardsInCluster
257247 }
258248 } ) ;
259- await waku . start ( ) ;
260249 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
261250
262251 // ensure the connection is closed from the other side
@@ -278,7 +267,7 @@ describe("Metadata Protocol", function () {
278267 const contentTopic = [ "/foo/1/bar/proto" ] ;
279268 const numShardsInCluster = 0 ;
280269
281- await nwaku1 . start ( {
270+ nwaku1 = await startServiceNode ( this , {
282271 relay : true ,
283272 discv5Discovery : true ,
284273 peerExchange : true ,
@@ -289,10 +278,9 @@ describe("Metadata Protocol", function () {
289278 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
290279 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
291280
292- waku = await createLightNode ( {
281+ waku = await startLightNode ( {
293282 networkConfig : { clusterId, numShardsInCluster }
294283 } ) ;
295- await waku . start ( ) ;
296284 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
297285
298286 // delay to ensure the connection is estabilished and shardInfo is updated
@@ -316,7 +304,7 @@ describe("Metadata Protocol", function () {
316304 const contentTopic = [ "/foo/1/bar/proto" ] ;
317305 const numShardsInCluster = 0 ;
318306
319- await nwaku1 . start ( {
307+ nwaku1 = await startServiceNode ( this , {
320308 relay : true ,
321309 discv5Discovery : true ,
322310 peerExchange : true ,
@@ -327,7 +315,7 @@ describe("Metadata Protocol", function () {
327315 const nwaku1Ma = await nwaku1 . getMultiaddrWithId ( ) ;
328316 const nwaku1PeerId = await nwaku1 . getPeerId ( ) ;
329317
330- waku = await createLightNode ( {
318+ waku = await startLightNode ( {
331319 networkConfig : {
332320 clusterId,
333321 numShardsInCluster
@@ -336,7 +324,6 @@ describe("Metadata Protocol", function () {
336324 pingKeepAlive : 1
337325 }
338326 } ) ;
339- await waku . start ( ) ;
340327 await waku . libp2p . dialProtocol ( nwaku1Ma , MetadataCodec ) ;
341328
342329 // delay to ensure the connection is estabilished, shardInfo is updated, and there is a ping
0 commit comments