mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
magicsock: test sequence of pings
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
parent
9f584414d9
commit
caec2c7e8b
@ -353,4 +353,31 @@ func TestTwoDevicePing(t *testing.T) {
|
|||||||
ping1(t)
|
ping1(t)
|
||||||
ping2(t)
|
ping2(t)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("ping 1.0.0.1 x50", func(t *testing.T) {
|
||||||
|
const count = 50
|
||||||
|
|
||||||
|
msg := func(i int) []byte {
|
||||||
|
b := tuntest.Ping(net.ParseIP("1.0.0.2"), net.ParseIP("1.0.0.1"))
|
||||||
|
b[len(b)-1] = byte(i) // set seq num
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < count; i++ {
|
||||||
|
b := msg(i)
|
||||||
|
tun1.Outbound <- b
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < count; i++ {
|
||||||
|
b := msg(i)
|
||||||
|
select {
|
||||||
|
case msgRecv := <-tun2.Inbound:
|
||||||
|
if !bytes.Equal(b, msgRecv) {
|
||||||
|
t.Errorf("return ping %d did not transit correctly", i)
|
||||||
|
}
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
t.Fatalf("return ping %d did not transit", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user