@@ -23,10 +23,10 @@ func TestSimpleLibp2pNetwork_synctest(t *testing.T) {
2323 latency := 10 * time .Millisecond
2424 network , meta , err := simlibp2p .SimpleLibp2pNetwork ([]simlibp2p.NodeLinkSettingsAndCount {
2525 {LinkSettings : simnet.NodeBiDiLinkSettings {
26- Downlink : simnet.LinkSettings {BitsPerSecond : 20 * simlibp2p .OneMbps , Latency : latency / 2 }, // Divide by two since this is latency for each direction
27- Uplink : simnet.LinkSettings {BitsPerSecond : 20 * simlibp2p .OneMbps , Latency : latency / 2 },
26+ Downlink : simnet.LinkSettings {BitsPerSecond : 20 * simlibp2p .OneMbps }, // Divide by two since this is latency for each direction
27+ Uplink : simnet.LinkSettings {BitsPerSecond : 20 * simlibp2p .OneMbps },
2828 }, Count : 100 },
29- }, simlibp2p.NetworkSettings {})
29+ }, simnet . StaticLatency ( latency / 2 ), simlibp2p.NetworkSettings {})
3030 require .NoError (t , err )
3131 network .Start ()
3232 defer network .Close ()
@@ -74,19 +74,17 @@ func TestSimpleLibp2pNetwork_synctest(t *testing.T) {
7474}
7575
7676func TestSimpleSimNetPing_synctest (t * testing.T ) {
77- synctest .Run (func () {
78- router := & simnet.Simnet {}
77+ synctest .Test (t , func (t * testing.T ) {
78+ const latency = 10 * time .Millisecond
79+ router := & simnet.Simnet {LatencyFunc : simnet .StaticLatency (latency / 2 )}
7980
8081 const bandwidth = 10 * simlibp2p .OneMbps
81- const latency = 10 * time .Millisecond
8282 linkSettings := simnet.NodeBiDiLinkSettings {
8383 Downlink : simnet.LinkSettings {
8484 BitsPerSecond : bandwidth ,
85- Latency : latency / 2 ,
8685 },
8786 Uplink : simnet.LinkSettings {
8887 BitsPerSecond : bandwidth ,
89- Latency : latency / 2 ,
9088 },
9189 }
9290
@@ -101,14 +99,13 @@ func TestSimpleSimNetPing_synctest(t *testing.T) {
10199 simlibp2p .QUICSimnet (router , linkSettings ),
102100 )
103101
104- err := router .Start ()
105- require .NoError (t , err )
102+ router .Start ()
106103 defer router .Close ()
107104
108105 defer hostA .Close ()
109106 defer hostB .Close ()
110107
111- err = hostA .Connect (context .Background (), peer.AddrInfo {
108+ err : = hostA .Connect (context .Background (), peer.AddrInfo {
112109 ID : hostB .ID (),
113110 Addrs : hostB .Addrs (),
114111 })
0 commit comments