Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
d29c0d3b
Commit
d29c0d3b
authored
Dec 20, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2d85f4aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
t/neo/connection.go
t/neo/connection.go
+1
-1
t/neo/connection_test.go
t/neo/connection_test.go
+29
-4
No files found.
t/neo/connection.go
View file @
d29c0d3b
...
...
@@ -161,7 +161,7 @@ func (nl *NodeLink) Close() error {
// send raw packet to peer
func
(
nl
*
NodeLink
)
sendPkt
(
pkt
*
PktBuf
)
error
{
_
,
err
:=
nl
.
peerLink
.
Write
(
pkt
.
Data
)
_
,
err
:=
nl
.
peerLink
.
Write
(
pkt
.
Data
)
// FIXME write Data in full
if
err
!=
nil
{
// XXX do we need to retry if err is temporary?
// TODO data could be written partially and thus the message stream is now broken
...
...
t/neo/connection_test.go
View file @
d29c0d3b
...
...
@@ -142,14 +142,31 @@ func nodeLinkPipe() (nl1, nl2 *NodeLink) {
return
_nodeLinkPipe
(
0
)
}
func
TestPipe
(
t
*
testing
.
T
)
{
p1
,
p2
:=
net
.
Pipe
()
wg
:=
WorkGroup
()
wg
.
Gox
(
func
()
{
tdelay
()
println
(
"aaa"
)
xclose
(
p1
)
println
(
"bbb"
)
})
println
(
"111"
)
_
,
err
:=
p1
.
Write
([]
byte
(
"data"
))
println
(
"222"
)
if
err
!=
io
.
ErrClosedPipe
{
t
.
Fatalf
(
"unexpected err = %v"
,
err
)
}
xwait
(
wg
)
xclose
(
p2
)
}
func
TestNodeLink
(
t
*
testing
.
T
)
{
// TODO catch exception -> add proper location from it -> t.Fatal (see git-backup)
nl1
,
nl2
:=
nodeLinkPipe
()
// Close vs recvPkt
println
(
"111"
)
nl1
,
nl2
:=
_nodeLinkPipe
(
connNoRecvSend
)
wg
:=
WorkGroup
()
wg
.
Gox
(
func
()
{
tdelay
()
...
...
@@ -160,20 +177,28 @@ func TestNodeLink(t *testing.T) {
t
.
Fatalf
(
"NodeLink.recvPkt() after close: pkt = %v err = %v"
,
pkt
,
err
)
}
xwait
(
wg
)
xclose
(
nl2
)
// Close vs sendPkt
println
(
"222"
)
nl1
,
nl2
=
_nodeLinkPipe
(
connNoRecvSend
)
wg
=
WorkGroup
()
wg
.
Gox
(
func
()
{
tdelay
()
xclose
(
nl2
)
println
(
"close(nl1) aaa"
)
xclose
(
nl1
)
println
(
"close(nl1) bbb"
)
})
pkt
=
&
PktBuf
{[]
byte
(
"data"
)}
err
=
nl2
.
sendPkt
(
pkt
)
println
(
"zzz"
)
err
=
nl1
.
sendPkt
(
pkt
)
println
(
"qqq"
)
if
err
!=
io
.
ErrClosedPipe
{
t
.
Fatalf
(
"NodeLink.sendPkt() after close: err = %v"
,
err
)
}
xwait
(
wg
)
xclose
(
nl2
)
return
// check raw exchange works
println
(
"333"
)
...
...
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