Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mf
go-multiaddr
Commits
ff7b6a79
Commit
ff7b6a79
authored
Mar 30, 2021
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't call T.Fatal in go routine
parent
7c39c5cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
net/net_test.go
net/net_test.go
+14
-17
No files found.
net/net_test.go
View file @
ff7b6a79
...
...
@@ -32,10 +32,9 @@ func TestDial(t *testing.T) {
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
go
func
()
{
cB
,
err
:=
listener
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
"failed to accept"
)
t
.
Error
(
"failed to accept"
)
}
// echo out
...
...
@@ -99,19 +98,19 @@ func TestUnixSockets(t *testing.T) {
go
func
()
{
conn
,
err
:=
listener
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Error
(
err
)
}
defer
conn
.
Close
()
buf
:=
make
([]
byte
,
1024
)
n
,
err
:=
conn
.
Read
(
buf
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Error
(
err
)
}
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
)
{
t
.
Fatal
(
"payload did not match"
)
t
.
Error
(
"payload did not match"
)
}
done
<-
struct
{}{}
}()
...
...
@@ -146,14 +145,13 @@ func TestListen(t *testing.T) {
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
go
func
()
{
cB
,
err
:=
listener
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
"failed to accept"
)
t
.
Error
(
"failed to accept"
)
}
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
...
...
@@ -267,14 +265,13 @@ func TestListenAndDial(t *testing.T) {
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
go
func
()
{
cB
,
err
:=
listener
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
"failed to accept"
)
t
.
Error
(
"failed to accept"
)
}
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
...
...
@@ -329,13 +326,13 @@ func TestListenPacketAndDial(t *testing.T) {
go
func
()
{
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
)
_
,
addr
,
err
:=
pc
.
ReadFrom
(
buffer
)
if
err
!=
nil
{
t
.
Fatal
(
"failed to read into buffer"
,
err
)
t
.
Error
(
"failed to read into buffer"
,
err
)
}
pc
.
WriteTo
(
buffer
,
addr
)
...
...
@@ -633,16 +630,16 @@ func TestNetListener(t *testing.T) {
go
func
()
{
c
,
err
:=
Dial
(
malist
.
Multiaddr
())
if
err
!=
nil
{
t
.
Fatal
(
"failed to dial"
)
t
.
Error
(
"failed to dial"
)
}
if
!
c
.
RemoteMultiaddr
()
.
Equal
(
malist
.
Multiaddr
())
{
t
.
Fatal
(
"dialed wrong target"
)
t
.
Error
(
"dialed wrong target"
)
}
c
.
Close
()
c
,
err
=
Dial
(
malist
.
Multiaddr
())
if
err
!=
nil
{
t
.
Fatal
(
"failed to dial"
)
t
.
Error
(
"failed to dial"
)
}
c
.
Close
()
}()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment