summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-02-08 11:36:55 -0800
committerJosh Bleecher Snyder <josh@tailscale.com>2021-02-08 12:01:08 -0800
commitaf408eb9400bd94a01eea5ece8fa3da62c911818 (patch)
tree4bc5a83b65490630a7bf94a1c355dc998a31e966
parent15810daa2283e3cfe0c811c3632f053274f31950 (diff)
device: print direction when ping transit fails
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r--device/device_test.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/device/device_test.go b/device/device_test.go
index 56ecd17..3ff35e7 100644
--- a/device/device_test.go
+++ b/device/device_test.go
@@ -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 {