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
dms3
go-dms3
Commits
5e8725db
Commit
5e8725db
authored
Jun 25, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: test to ensure closing right linsters
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
4c98edaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
core/commands/p2p.go
core/commands/p2p.go
+8
-1
p2p/local.go
p2p/local.go
+1
-2
test/sharness/t0180-p2p.sh
test/sharness/t0180-p2p.sh
+15
-4
No files found.
core/commands/p2p.go
View file @
5e8725db
...
...
@@ -338,8 +338,15 @@ var p2pCloseCmd = &cmds.Command{
}
n
.
P2P
.
Listeners
.
Unlock
()
var
errs
[]
string
for
_
,
l
:=
range
todo
{
l
.
Close
()
if
err
:=
l
.
Close
();
err
!=
nil
{
errs
=
append
(
errs
,
err
.
Error
())
}
}
if
len
(
errs
)
!=
0
{
res
.
SetError
(
fmt
.
Errorf
(
"errors when closing streams: %s"
,
strings
.
Join
(
errs
,
"; "
)),
cmdkit
.
ErrNormal
)
return
}
res
.
SetOutput
(
len
(
todo
))
...
...
p2p/local.go
View file @
5e8725db
...
...
@@ -109,8 +109,7 @@ func (l *localListener) Close() error {
return
err
}
if
ok
{
l
.
listener
.
Close
()
l
.
listener
=
nil
return
l
.
listener
.
Close
()
}
return
nil
}
...
...
test/sharness/t0180-p2p.sh
View file @
5e8725db
...
...
@@ -233,16 +233,27 @@ test_expect_success "'ipfs p2p close' closes app numeric handlers" '
test_must_be_empty actual
'
test_expect_success
"'ipfs p2p close' closes by
listen
addr"
'
test_expect_success
"'ipfs p2p close' closes by
target
addr"
'
ipfsi 0 p2p listen /x/p2p-test /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 p2p close -
l
/ip
fs/$PEERID_0
&&
ipfsi 0 p2p close -
t
/ip
4/127.0.0.1/tcp/10101
&&
ipfsi 0 p2p ls > actual &&
test_must_be_empty actual
'
test_expect_success
"'ipfs p2p close' closes
by target addr
"
'
test_expect_success
"'ipfs p2p close' closes
right listeners
"
'
ipfsi 0 p2p listen /x/p2p-test /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 p2p close -t /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 p2p forward /x/p2p-test /ip4/127.0.0.1/tcp/10101 /ipfs/$PEERID_1 &&
echo "/x/p2p-test /ipfs/$PEERID_0 /ip4/127.0.0.1/tcp/10101" > expected &&
ipfsi 0 p2p close -l /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 p2p ls > actual &&
test_cmp expected actual
'
check_test_ports
test_expect_success
"'ipfs p2p close' closes by listen addr"
'
ipfsi 0 p2p close -l /ipfs/$PEERID_0 &&
ipfsi 0 p2p ls > actual &&
test_must_be_empty actual
'
...
...
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