]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: print direction when ping transit fails
authorJosh Bleecher Snyder <josh@tailscale.com>
Mon, 8 Feb 2021 19:36:55 +0000 (11:36 -0800)
committerJosh Bleecher Snyder <josh@tailscale.com>
Mon, 8 Feb 2021 20:01:08 +0000 (12:01 -0800)
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
device/device_test.go

index 56ecd17cf09a903ec6d89057e838003106478fdf..3ff35e77328884a3c177e43959f6c2a487dd9633 100644 (file)
@@ -8,7 +8,6 @@ package device
 import (
        "bytes"
        "encoding/hex"
-       "errors"
        "fmt"
        "io/ioutil"
        "math/rand"
@@ -103,6 +102,13 @@ const (
        Pong SendDirection = false
 )
 
+func (d SendDirection) String() string {
+       if d == Ping {
+               return "ping"
+       }
+       return "pong"
+}
+
 func (pair *testPair) Send(tb testing.TB, ping SendDirection, done chan struct{}) {
        tb.Helper()
        p0, p1 := pair[0], pair[1]
@@ -118,10 +124,10 @@ func (pair *testPair) Send(tb testing.TB, ping SendDirection, done chan struct{}
        select {
        case msgRecv := <-p0.tun.Inbound:
                if !bytes.Equal(msg, msgRecv) {
-                       err = errors.New("ping did not transit correctly")
+                       err = fmt.Errorf("%s did not transit correctly", ping)
                }
        case <-timer.C:
-               err = errors.New("ping did not transit")
+               err = fmt.Errorf("%s did not transit", ping)
        case <-done:
        }
        if err != nil {