@@ -255,71 +255,71 @@ suite "Waku ENR - Multiaddresses":
255
255
256
256
suite " Waku ENR - Relay static sharding" :
257
257
258
- test " new relay shards field with single invalid index " :
258
+ test " new relay shards object with single invalid shard id " :
259
259
# # Given
260
260
let
261
- shardCluster : uint16 = 22
262
- shardIndex : uint16 = 1024
261
+ clusterId : uint16 = 22
262
+ shard : uint16 = 1024
263
263
264
264
# # When
265
- let res = RelayShards .init (shardCluster, shardIndex )
265
+ let shardsTopics = RelayShards .init (clusterId, shard )
266
266
267
267
# # Then
268
- assert res .isErr (), $ res .get ()
268
+ assert shardsTopics .isErr (), $ shardsTopics .get ()
269
269
270
- test " new relay shards field with single invalid index in list" :
270
+ test " new relay shards object with single invalid shard id in list" :
271
271
# # Given
272
272
let
273
- shardCluster : uint16 = 22
274
- shardIndices : seq [uint16 ] = @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 , 1024 u16 ]
273
+ clusterId : uint16 = 22
274
+ shardIds : seq [uint16 ] = @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 , 1024 u16 ]
275
275
276
276
# # When
277
- let res = RelayShards .init (shardCluster, shardIndices )
277
+ let shardsTopics = RelayShards .init (clusterId, shardIds )
278
278
279
279
# # Then
280
- assert res .isErr (), $ res .get ()
280
+ assert shardsTopics .isErr (), $ shardsTopics .get ()
281
281
282
- test " new relay shards field with single valid index " :
282
+ test " new relay shards object with single valid shard id " :
283
283
# # Given
284
284
let
285
- shardCluster : uint16 = 22
286
- shardIndex : uint16 = 1
285
+ clusterId : uint16 = 22
286
+ shardId : uint16 = 1
287
287
288
- let topic = NsPubsubTopic .staticSharding (shardCluster, shardIndex )
288
+ let topic = NsPubsubTopic .staticSharding (clusterId, shardId )
289
289
290
290
# # When
291
- let shards = RelayShards .init (shardCluster, shardIndex ).expect (" Valid Shards" )
291
+ let shardsTopics = RelayShards .init (clusterId, shardId ).expect (" Valid Shards" )
292
292
293
293
# # Then
294
294
check:
295
- shards.cluster == shardCluster
296
- shards.indices == @ [1 u16 ]
295
+ shardsTopics.clusterId == clusterId
296
+ shardsTopics.shardIds == @ [1 u16 ]
297
297
298
- let topics = shards .topics.mapIt ($ it)
298
+ let topics = shardsTopics .topics.mapIt ($ it)
299
299
check:
300
300
topics == @ [$ topic]
301
301
302
302
check:
303
- shards .contains (shardCluster, shardIndex )
304
- not shards .contains (shardCluster , 33 u16 )
305
- not shards .contains (20 u16 , 33 u16 )
303
+ shardsTopics .contains (clusterId, shardId )
304
+ not shardsTopics .contains (clusterId , 33 u16 )
305
+ not shardsTopics .contains (20 u16 , 33 u16 )
306
306
307
- shards .contains (topic)
308
- shards .contains (" /waku/2/rs/22/1" )
307
+ shardsTopics .contains (topic)
308
+ shardsTopics .contains (" /waku/2/rs/22/1" )
309
309
310
- test " new relay shards field with repeated but valid indices " :
310
+ test " new relay shards object with repeated but valid shard ids " :
311
311
# # Given
312
312
let
313
- shardCluster : uint16 = 22
314
- shardIndices : seq [uint16 ] = @ [1 u16 , 2 u16 , 2 u16 , 3 u16 , 3 u16 , 3 u16 ]
313
+ clusterId : uint16 = 22
314
+ shardIds : seq [uint16 ] = @ [1 u16 , 2 u16 , 2 u16 , 3 u16 , 3 u16 , 3 u16 ]
315
315
316
316
# # When
317
- let shards = RelayShards .init (shardCluster, shardIndices ).expect (" Valid Shards" )
317
+ let shardsTopics = RelayShards .init (clusterId, shardIds ).expect (" Valid Shards" )
318
318
319
319
# # Then
320
320
check:
321
- shards.cluster == shardCluster
322
- shards.indices == @ [1 u16 , 2 u16 , 3 u16 ]
321
+ shardsTopics.clusterId == clusterId
322
+ shardsTopics.shardIds == @ [1 u16 , 2 u16 , 3 u16 ]
323
323
324
324
test " cannot decode relay shards from record if not present" :
325
325
# # Given
@@ -338,21 +338,21 @@ suite "Waku ENR - Relay static sharding":
338
338
# # Then
339
339
check fieldOpt.isNone ()
340
340
341
- test " encode and decode record with relay shards field (EnrBuilder ext - indices list)" :
341
+ test " encode and decode record with relay shards field (EnrBuilder ext - shardIds list)" :
342
342
# # Given
343
343
let
344
344
enrSeqNum = 1 u64
345
345
enrPrivKey = generatesecp256k1key ()
346
346
347
347
let
348
- shardCluster : uint16 = 22
349
- shardIndices : seq [uint16 ] = @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 ]
348
+ clusterId : uint16 = 22
349
+ shardIds : seq [uint16 ] = @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 ]
350
350
351
- let shards = RelayShards .init (shardCluster, shardIndices ).expect (" Valid Shards" )
351
+ let shardsTopics = RelayShards .init (clusterId, shardIds ).expect (" Valid Shards" )
352
352
353
353
# # When
354
354
var builder = EnrBuilder .init (enrPrivKey, seqNum = enrSeqNum)
355
- require builder.withWakuRelaySharding (shards ).isOk ()
355
+ require builder.withWakuRelaySharding (shardsTopics ).isOk ()
356
356
357
357
let recordRes = builder.build ()
358
358
@@ -366,18 +366,18 @@ suite "Waku ENR - Relay static sharding":
366
366
let shardsOpt = typedRecord.value.relaySharding
367
367
check:
368
368
shardsOpt.isSome ()
369
- shardsOpt.get () == shards
369
+ shardsOpt.get () == shardsTopics
370
370
371
371
test " encode and decode record with relay shards field (EnrBuilder ext - bit vector)" :
372
372
# # Given
373
373
let
374
374
enrSeqNum = 1 u64
375
375
enrPrivKey = generatesecp256k1key ()
376
376
377
- let shards = RelayShards .init (33 , toSeq (0 u16 ..< 64 u16 )).expect (" Valid Shards" )
377
+ let shardsTopics = RelayShards .init (33 , toSeq (0 u16 ..< 64 u16 )).expect (" Valid Shards" )
378
378
379
379
var builder = EnrBuilder .init (enrPrivKey, seqNum = enrSeqNum)
380
- require builder.withWakuRelaySharding (shards ).isOk ()
380
+ require builder.withWakuRelaySharding (shardsTopics ).isOk ()
381
381
382
382
let recordRes = builder.build ()
383
383
require recordRes.isOk ()
@@ -393,22 +393,22 @@ suite "Waku ENR - Relay static sharding":
393
393
# # Then
394
394
check:
395
395
shardsOpt.isSome ()
396
- shardsOpt.get () == shards
396
+ shardsOpt.get () == shardsTopics
397
397
398
- test " decode record with relay shards indices list and bit vector fields" :
398
+ test " decode record with relay shards shard list and bit vector fields" :
399
399
# # Given
400
400
let
401
401
enrSeqNum = 1 u64
402
402
enrPrivKey = generatesecp256k1key ()
403
403
404
404
let
405
- shardsIndicesList = RelayShards .init (22 , @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 ]).expect (" Valid Shards" )
406
- shardsBitVector = RelayShards .init (33 , @ [13 u16 , 24 u16 , 37 u16 , 61 u16 , 98 u16 , 159 u16 ]).expect (" Valid Shards" )
405
+ relayShardsIndicesList = RelayShards .init (22 , @ [1 u16 , 1 u16 , 2 u16 , 3 u16 , 5 u16 , 8 u16 ]).expect (" Valid Shards" )
406
+ relayShardsBitVector = RelayShards .init (33 , @ [13 u16 , 24 u16 , 37 u16 , 61 u16 , 98 u16 , 159 u16 ]).expect (" Valid Shards" )
407
407
408
408
409
409
var builder = EnrBuilder .init (enrPrivKey, seqNum = enrSeqNum)
410
- require builder.withWakuRelayShardingIndicesList (shardsIndicesList ).isOk ()
411
- require builder.withWakuRelayShardingBitVector (shardsBitVector ).isOk ()
410
+ require builder.withWakuRelayShardingIndicesList (relayShardsIndicesList ).isOk ()
411
+ require builder.withWakuRelayShardingBitVector (relayShardsBitVector ).isOk ()
412
412
413
413
let recordRes = builder.build ()
414
414
require recordRes.isOk ()
@@ -424,4 +424,4 @@ suite "Waku ENR - Relay static sharding":
424
424
# # Then
425
425
check:
426
426
shardsOpt.isSome ()
427
- shardsOpt.get () == shardsIndicesList
427
+ shardsOpt.get () == relayShardsIndicesList
0 commit comments