Commit ff7b6a79 authored by Marten Seemann's avatar Marten Seemann

don't call T.Fatal in go routine

parent 7c39c5cf
...@@ -32,10 +32,9 @@ func TestDial(t *testing.T) { ...@@ -32,10 +32,9 @@ func TestDial(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
cB, err := listener.Accept() cB, err := listener.Accept()
if err != nil { if err != nil {
t.Fatal("failed to accept") t.Error("failed to accept")
} }
// echo out // echo out
...@@ -99,19 +98,19 @@ func TestUnixSockets(t *testing.T) { ...@@ -99,19 +98,19 @@ func TestUnixSockets(t *testing.T) {
go func() { go func() {
conn, err := listener.Accept() conn, err := listener.Accept()
if err != nil { if err != nil {
t.Fatal(err) t.Error(err)
} }
defer conn.Close() defer conn.Close()
buf := make([]byte, 1024) buf := make([]byte, 1024)
n, err := conn.Read(buf) n, err := conn.Read(buf)
if err != nil { if err != nil {
t.Fatal(err) t.Error(err)
} }
if n != len(payload) { if n != len(payload) {
t.Fatal("failed to read appropriate number of bytes") t.Error("failed to read appropriate number of bytes")
} }
if !bytes.Equal(buf[0:n], payload) { if !bytes.Equal(buf[0:n], payload) {
t.Fatal("payload did not match") t.Error("payload did not match")
} }
done <- struct{}{} done <- struct{}{}
}() }()
...@@ -146,14 +145,13 @@ func TestListen(t *testing.T) { ...@@ -146,14 +145,13 @@ func TestListen(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
cB, err := listener.Accept() cB, err := listener.Accept()
if err != nil { if err != nil {
t.Fatal("failed to accept") t.Error("failed to accept")
} }
if !cB.LocalMultiaddr().Equal(maddr) { if !cB.LocalMultiaddr().Equal(maddr) {
t.Fatal("local multiaddr not equal:", maddr, cB.LocalMultiaddr()) t.Error("local multiaddr not equal:", maddr, cB.LocalMultiaddr())
} }
// echo out // echo out
...@@ -267,14 +265,13 @@ func TestListenAndDial(t *testing.T) { ...@@ -267,14 +265,13 @@ func TestListenAndDial(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
cB, err := listener.Accept() cB, err := listener.Accept()
if err != nil { if err != nil {
t.Fatal("failed to accept") t.Error("failed to accept")
} }
if !cB.LocalMultiaddr().Equal(maddr) { if !cB.LocalMultiaddr().Equal(maddr) {
t.Fatal("local multiaddr not equal:", maddr, cB.LocalMultiaddr()) t.Error("local multiaddr not equal:", maddr, cB.LocalMultiaddr())
} }
// echo out // echo out
...@@ -329,13 +326,13 @@ func TestListenPacketAndDial(t *testing.T) { ...@@ -329,13 +326,13 @@ func TestListenPacketAndDial(t *testing.T) {
go func() { go func() {
if !pc.LocalMultiaddr().Equal(maddr) { if !pc.LocalMultiaddr().Equal(maddr) {
t.Fatal("connection multiaddr not equal:", maddr, pc.LocalMultiaddr()) t.Error("connection multiaddr not equal:", maddr, pc.LocalMultiaddr())
} }
buffer := make([]byte, 1024) buffer := make([]byte, 1024)
_, addr, err := pc.ReadFrom(buffer) _, addr, err := pc.ReadFrom(buffer)
if err != nil { if err != nil {
t.Fatal("failed to read into buffer", err) t.Error("failed to read into buffer", err)
} }
pc.WriteTo(buffer, addr) pc.WriteTo(buffer, addr)
...@@ -633,16 +630,16 @@ func TestNetListener(t *testing.T) { ...@@ -633,16 +630,16 @@ func TestNetListener(t *testing.T) {
go func() { go func() {
c, err := Dial(malist.Multiaddr()) c, err := Dial(malist.Multiaddr())
if err != nil { if err != nil {
t.Fatal("failed to dial") t.Error("failed to dial")
} }
if !c.RemoteMultiaddr().Equal(malist.Multiaddr()) { if !c.RemoteMultiaddr().Equal(malist.Multiaddr()) {
t.Fatal("dialed wrong target") t.Error("dialed wrong target")
} }
c.Close() c.Close()
c, err = Dial(malist.Multiaddr()) c, err = Dial(malist.Multiaddr())
if err != nil { if err != nil {
t.Fatal("failed to dial") t.Error("failed to dial")
} }
c.Close() c.Close()
}() }()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment