Skip to content

Commit cc71244

Browse files
committed
fix(tests): more v2.0.0 API migrations (rng template, PeerId.random, etc.)
- tests/test_wakunode.nim: add std/options for Option.some disambiguation - tests/test_peer_manager.nim: replace .withRng(rng) with .withRng( crypto.newRng()); PeerId.random() now takes Rng - tests/test_waku_keepalive.nim: Ping.new now requires rng: Rng arg - tests/test_waku_dnsdisc.nim: qualify ambiguous rng as common.rng()
1 parent 328e11d commit cc71244

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

tests/test_peer_manager.nim

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,11 @@ procSuite "Peer Manager":
955955

956956
# Create peer manager
957957
let pm = PeerManager.new(
958-
switch = SwitchBuilder.new().withRng(rng).withMplex().withNoise().build(),
958+
switch = SwitchBuilder.new()
959+
.withRng(crypto.newRng())
960+
.withMplex()
961+
.withNoise()
962+
.build(),
959963
storage = nil,
960964
)
961965

@@ -1013,7 +1017,7 @@ procSuite "Peer Manager":
10131017
let pm = PeerManager.new(
10141018
switch = SwitchBuilder
10151019
.new()
1016-
.withRng(rng)
1020+
.withRng(crypto.newRng())
10171021
.withMplex()
10181022
.withNoise()
10191023
.withPeerStore(peerStoreSize)
@@ -1027,7 +1031,7 @@ procSuite "Peer Manager":
10271031
let pm = PeerManager.new(
10281032
switch = SwitchBuilder
10291033
.new()
1030-
.withRng(rng)
1034+
.withRng(crypto.newRng())
10311035
.withMplex()
10321036
.withNoise()
10331037
.withPeerStore(25)
@@ -1040,7 +1044,7 @@ procSuite "Peer Manager":
10401044

10411045
# Create 30 peers and add them to the peerstore
10421046
let peers = toSeq(1 .. 30)
1043-
.mapIt(parsePeerInfo("/ip4/0.0.0.0/tcp/0/p2p/" & $PeerId.random().get()))
1047+
.mapIt(parsePeerInfo("/ip4/0.0.0.0/tcp/0/p2p/" & $PeerId.random(crypto.newRng()).get()))
10441048
.filterIt(it.isOk())
10451049
.mapIt(it.value)
10461050
for p in peers:
@@ -1091,7 +1095,7 @@ procSuite "Peer Manager":
10911095
let pm = PeerManager.new(
10921096
switch = SwitchBuilder
10931097
.new()
1094-
.withRng(rng)
1098+
.withRng(crypto.newRng())
10951099
.withMplex()
10961100
.withNoise()
10971101
.withPeerStore(25)
@@ -1148,7 +1152,7 @@ procSuite "Peer Manager":
11481152
let pm = PeerManager.new(
11491153
switch = SwitchBuilder
11501154
.new()
1151-
.withRng(rng)
1155+
.withRng(crypto.newRng())
11521156
.withMplex()
11531157
.withNoise()
11541158
.withPeerStore(25)
@@ -1164,7 +1168,7 @@ procSuite "Peer Manager":
11641168
let pm = PeerManager.new(
11651169
switch = SwitchBuilder
11661170
.new()
1167-
.withRng(rng)
1171+
.withRng(crypto.newRng())
11681172
.withMplex()
11691173
.withNoise()
11701174
.withPeerStore(25)
@@ -1178,7 +1182,7 @@ procSuite "Peer Manager":
11781182
let pm = PeerManager.new(
11791183
switch = SwitchBuilder
11801184
.new()
1181-
.withRng(rng)
1185+
.withRng(crypto.newRng())
11821186
.withMplex()
11831187
.withNoise()
11841188
.withPeerStore(25)
@@ -1327,7 +1331,7 @@ procSuite "Peer Manager":
13271331

13281332
# Create peer manager
13291333
let pm = PeerManager.new(
1330-
switch = SwitchBuilder.new().withRng(rng()).withMplex().withNoise().build(),
1334+
switch = SwitchBuilder.new().withRng(crypto.newRng()).withMplex().withNoise().build(),
13311335
storage = nil,
13321336
)
13331337

tests/test_waku_dnsdisc.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ suite "Waku DNS Discovery":
5252
)
5353
.get() # No link entries
5454

55-
let treeKeys = keys.KeyPair.random(rng[])
55+
let treeKeys = keys.KeyPair.random(common.rng()[])
5656

5757
# Sign tree
5858
check:

tests/test_waku_keepalive.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ suite "Waku Keepalive":
3838
(await node2.mountRelay()).isOkOr:
3939
assert false, "Failed to mount relay"
4040

41-
let pingProto = Ping.new(handler = pingHandler)
41+
let pingProto = Ping.new(handler = pingHandler, rng = crypto.newRng())
4242
await pingProto.start()
4343
node2.switch.mount(pingProto)
4444

tests/test_wakunode.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{.used.}
22

33
import
4-
std/[sequtils, strutils, net],
4+
std/[options, sequtils, strutils, net],
55
stew/byteutils,
66
testutils/unittests,
77
chronicles,

0 commit comments

Comments
 (0)