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
2d01bfb2
Commit
2d01bfb2
authored
Jul 06, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
81e20e01
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
go/neo/neonet/connection_test.go
go/neo/neonet/connection_test.go
+18
-19
No files found.
go/neo/neonet/connection_test.go
View file @
2d01bfb2
...
@@ -36,8 +36,8 @@ import (
...
@@ -36,8 +36,8 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/packed"
"lab.nexedi.com/kirr/neo/go/internal/packed"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/zodb"
"github.com/kylelemons/godebug/pretty"
"github.com/kylelemons/godebug/pretty"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -60,23 +60,23 @@ func xaccept(nl *NodeLink) *Conn {
...
@@ -60,23 +60,23 @@ func xaccept(nl *NodeLink) *Conn {
return
c
return
c
}
}
func
xsendPkt
(
c
interface
{
sendPkt
(
*
pktBuf
)
error
},
pkt
*
pktBuf
)
{
func
xsendPkt
(
c
interface
{
sendPkt
(
*
pktBuf
)
error
},
pkt
*
pktBuf
)
{
err
:=
c
.
sendPkt
(
pkt
)
err
:=
c
.
sendPkt
(
pkt
)
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
}
}
func
xrecvPkt
(
c
interface
{
recvPkt
()
(
*
pktBuf
,
error
)
})
*
pktBuf
{
func
xrecvPkt
(
c
interface
{
recvPkt
()
(
*
pktBuf
,
error
)
})
*
pktBuf
{
pkt
,
err
:=
c
.
recvPkt
()
pkt
,
err
:=
c
.
recvPkt
()
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
return
pkt
return
pkt
}
}
func
xwait
(
w
interface
{
Wait
()
error
})
{
func
xwait
(
w
interface
{
Wait
()
error
})
{
err
:=
w
.
Wait
()
err
:=
w
.
Wait
()
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
}
}
func
gox
(
wg
interface
{
Go
(
func
()
error
)
},
xf
func
())
{
func
gox
(
wg
interface
{
Go
(
func
()
error
)
},
xf
func
())
{
wg
.
Go
(
exc
.
Funcx
(
xf
))
wg
.
Go
(
exc
.
Funcx
(
xf
))
}
}
...
@@ -100,7 +100,7 @@ func xconnError(err error) error {
...
@@ -100,7 +100,7 @@ func xconnError(err error) error {
// Prepare pktBuf with content.
// Prepare pktBuf with content.
func
_mkpkt
(
connid
uint32
,
msgcode
uint16
,
payload
[]
byte
)
*
pktBuf
{
func
_mkpkt
(
connid
uint32
,
msgcode
uint16
,
payload
[]
byte
)
*
pktBuf
{
pkt
:=
&
pktBuf
{
make
([]
byte
,
proto
.
PktHeaderLen
+
len
(
payload
))}
pkt
:=
&
pktBuf
{
make
([]
byte
,
proto
.
PktHeaderLen
+
len
(
payload
))}
h
:=
pkt
.
Header
()
h
:=
pkt
.
Header
()
h
.
ConnId
=
packed
.
Hton32
(
connid
)
h
.
ConnId
=
packed
.
Hton32
(
connid
)
h
.
MsgCode
=
packed
.
Hton16
(
msgcode
)
h
.
MsgCode
=
packed
.
Hton16
(
msgcode
)
...
@@ -133,7 +133,7 @@ func xverifyPkt(pkt *pktBuf, connid uint32, msgcode uint16, payload []byte) {
...
@@ -133,7 +133,7 @@ func xverifyPkt(pkt *pktBuf, connid uint32, msgcode uint16, payload []byte) {
pretty
.
Compare
(
string
(
payload
),
string
(
pkt
.
Payload
())))
pretty
.
Compare
(
string
(
payload
),
string
(
pkt
.
Payload
())))
}
}
exc
.
Raiseif
(
errv
.
Err
()
)
exc
.
Raiseif
(
errv
.
Err
()
)
}
}
// Verify pktBuf to match expected message.
// Verify pktBuf to match expected message.
...
@@ -154,14 +154,14 @@ func xverifyPktMsg(pkt *pktBuf, connid uint32, msg proto.Msg) {
...
@@ -154,14 +154,14 @@ func xverifyPktMsg(pkt *pktBuf, connid uint32, msg proto.Msg) {
// -> this way we can know that it is already blocking and thus sleep-hack can be avoided
// -> this way we can know that it is already blocking and thus sleep-hack can be avoided
// this can be done via runtime/pprof -> "goroutine" predefined profile
// this can be done via runtime/pprof -> "goroutine" predefined profile
func
tdelay
()
{
func
tdelay
()
{
time
.
Sleep
(
1
*
time
.
Millisecond
)
time
.
Sleep
(
1
*
time
.
Millisecond
)
}
}
// create NodeLinks connected via net.Pipe
// create NodeLinks connected via net.Pipe
func
_nodeLinkPipe
(
flags1
,
flags2
_LinkRole
)
(
nl1
,
nl2
*
NodeLink
)
{
func
_nodeLinkPipe
(
flags1
,
flags2
_LinkRole
)
(
nl1
,
nl2
*
NodeLink
)
{
node1
,
node2
:=
net
.
Pipe
()
node1
,
node2
:=
net
.
Pipe
()
nl1
=
newNodeLink
(
node1
,
_LinkClient
|
flags1
)
nl1
=
newNodeLink
(
node1
,
_LinkClient
|
flags1
)
nl2
=
newNodeLink
(
node2
,
_LinkServer
|
flags2
)
nl2
=
newNodeLink
(
node2
,
_LinkServer
|
flags2
)
return
nl1
,
nl2
return
nl1
,
nl2
}
}
...
@@ -461,8 +461,7 @@ func TestNodeLink(t *testing.T) {
...
@@ -461,8 +461,7 @@ func TestNodeLink(t *testing.T) {
saveKeepClosed
:=
connKeepClosed
saveKeepClosed
:=
connKeepClosed
connKeepClosed
=
10
*
time
.
Millisecond
connKeepClosed
=
10
*
time
.
Millisecond
// Conn accept + exchange
// Conn accept + exchange
nl1
,
nl2
=
nodeLinkPipe
()
nl1
,
nl2
=
nodeLinkPipe
()
...
...
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