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
f5b60fb0
Commit
f5b60fb0
authored
Apr 20, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6e414cfd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
55 deletions
+59
-55
go/neo/neo_events_test.go
go/neo/neo_events_test.go
+49
-0
go/neo/neo_test.go
go/neo/neo_test.go
+7
-55
go/neo/neo_tracego_test.go
go/neo/neo_tracego_test.go
+2
-0
go/neo/proto/proto-misc.go
go/neo/proto/proto-misc.go
+1
-0
No files found.
go/neo/neo_events_test.go
View file @
f5b60fb0
...
@@ -88,6 +88,55 @@ func masterStartReady(where string, ready bool) *eventMStartReady {
...
@@ -88,6 +88,55 @@ func masterStartReady(where string, ready bool) *eventMStartReady {
// TODO eventPartTab
// TODO eventPartTab
// ---- shortcuts ----
// shortcut for net connect event
func
netconnect
(
src
,
dst
,
dialed
string
)
*
eventNetConnect
{
return
&
eventNetConnect
{
Src
:
src
,
Dst
:
dst
,
Dialed
:
dialed
}
}
func
netlisten
(
laddr
string
)
*
eventNetListen
{
return
&
eventNetListen
{
Laddr
:
laddr
}
}
// shortcut for net tx event over nodelink connection
func
conntx
(
src
,
dst
string
,
connid
uint32
,
msg
proto
.
Msg
)
*
eventNeoSend
{
return
&
eventNeoSend
{
Src
:
src
,
Dst
:
dst
,
ConnID
:
connid
,
Msg
:
msg
}
}
// shortcut for address
func
xnaddr
(
addr
string
)
proto
.
Address
{
if
addr
==
""
{
return
proto
.
Address
{}
}
// during testing we pretend addr is always of host:port form
a
,
err
:=
proto
.
AddrString
(
"tcp"
,
addr
)
if
err
!=
nil
{
panic
(
err
)
}
return
a
}
// shortcut for NodeInfo
func
nodei
(
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
proto
.
NodeInfo
{
return
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
proto
.
UUID
(
typ
,
num
),
State
:
state
,
IdTime
:
idtime
,
}
}
// shortcut for nodetab change
func
δnode
(
where
string
,
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
*
eventNodeTab
{
return
&
eventNodeTab
{
Where
:
where
,
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtime
),
}
}
// ---- events routing ----
// ---- events routing ----
// EventRouter implements NEO-specific routing of events to trace test channels.
// EventRouter implements NEO-specific routing of events to trace test channels.
...
...
go/neo/neo_test.go
View file @
f5b60fb0
...
@@ -108,54 +108,6 @@ func TestMasterStorage(t *testing.T) {
...
@@ -108,54 +108,6 @@ func TestMasterStorage(t *testing.T) {
tracer
.
Attach
()
tracer
.
Attach
()
defer
tracer
.
Detach
()
defer
tracer
.
Detach
()
// shortcut for addresses
xaddr
:=
func
(
addr
string
)
*
pipenet
.
Addr
{
a
,
err
:=
net
.
ParseAddr
(
addr
)
exc
.
Raiseif
(
err
)
return
a
}
xnaddr
:=
func
(
addr
string
)
proto
.
Address
{
if
addr
==
""
{
return
proto
.
Address
{}
}
a
,
err
:=
proto
.
Addr
(
xaddr
(
addr
))
exc
.
Raiseif
(
err
)
return
a
}
// shortcut for net connect event
netconnect
:=
func
(
src
,
dst
,
dialed
string
)
*
eventNetConnect
{
return
&
eventNetConnect
{
Src
:
src
,
Dst
:
dst
,
Dialed
:
dialed
}
}
netlisten
:=
func
(
laddr
string
)
*
eventNetListen
{
return
&
eventNetListen
{
Laddr
:
laddr
}
}
// shortcut for net tx event over nodelink connection
conntx
:=
func
(
src
,
dst
string
,
connid
uint32
,
msg
proto
.
Msg
)
*
eventNeoSend
{
return
&
eventNeoSend
{
Src
:
src
,
Dst
:
dst
,
ConnID
:
connid
,
Msg
:
msg
}
}
// shortcut for NodeInfo
nodei
:=
func
(
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
proto
.
NodeInfo
{
return
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
proto
.
UUID
(
typ
,
num
),
State
:
state
,
IdTime
:
idtime
,
}
}
// shortcut for nodetab change
node
:=
func
(
where
string
,
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
*
eventNodeTab
{
return
&
eventNodeTab
{
Where
:
where
,
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtime
),
}
}
// XXX -> M = testenv.NewMaster("m") (mkhost, chan, register to tracer ...)
// XXX -> M = testenv.NewMaster("m") (mkhost, chan, register to tracer ...)
// XXX ----//---- S, C
// XXX ----//---- S, C
...
@@ -230,7 +182,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -230,7 +182,7 @@ func TestMasterStorage(t *testing.T) {
// M starts listening
// M starts listening
tM
.
Expect
(
netlisten
(
"m:1"
))
tM
.
Expect
(
netlisten
(
"m:1"
))
tM
.
Expect
(
node
(
"m"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
proto
.
IdTimeNone
))
tM
.
Expect
(
δ
node
(
"m"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
proto
.
IdTimeNone
))
tM
.
Expect
(
clusterState
(
"m"
,
proto
.
ClusterRecovering
))
tM
.
Expect
(
clusterState
(
"m"
,
proto
.
ClusterRecovering
))
// TODO create C; C tries connect to master - rejected ("not yet operational")
// TODO create C; C tries connect to master - rejected ("not yet operational")
...
@@ -248,7 +200,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -248,7 +200,7 @@ func TestMasterStorage(t *testing.T) {
IdTime
:
proto
.
IdTimeNone
,
IdTime
:
proto
.
IdTimeNone
,
}))
}))
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
PENDING
,
0.01
))
tM
.
Expect
(
δ
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
PENDING
,
0.01
))
tSM
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
proto
.
AcceptIdentification
{
tSM
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
proto
.
AcceptIdentification
{
NodeType
:
proto
.
MASTER
,
NodeType
:
proto
.
MASTER
,
...
@@ -290,7 +242,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -290,7 +242,7 @@ func TestMasterStorage(t *testing.T) {
// trace
// trace
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
RUNNING
,
0.01
))
tM
.
Expect
(
δ
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
RUNNING
,
0.01
))
xwait
(
wg
)
xwait
(
wg
)
// XXX M.partTab <- S1
// XXX M.partTab <- S1
...
@@ -362,7 +314,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -362,7 +314,7 @@ func TestMasterStorage(t *testing.T) {
IdTime
:
proto
.
IdTimeNone
,
IdTime
:
proto
.
IdTimeNone
,
}))
}))
tM
.
Expect
(
node
(
"m"
,
""
,
proto
.
CLIENT
,
1
,
proto
.
RUNNING
,
0.02
))
tM
.
Expect
(
δ
node
(
"m"
,
""
,
proto
.
CLIENT
,
1
,
proto
.
RUNNING
,
0.02
))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
proto
.
AcceptIdentification
{
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
proto
.
AcceptIdentification
{
NodeType
:
proto
.
MASTER
,
NodeType
:
proto
.
MASTER
,
...
@@ -393,9 +345,9 @@ func TestMasterStorage(t *testing.T) {
...
@@ -393,9 +345,9 @@ func TestMasterStorage(t *testing.T) {
},
},
}))
}))
tMC
.
Expect
(
node
(
"c"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
proto
.
IdTimeNone
))
tMC
.
Expect
(
δ
node
(
"c"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
proto
.
IdTimeNone
))
tMC
.
Expect
(
node
(
"c"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
RUNNING
,
0.01
))
tMC
.
Expect
(
δ
node
(
"c"
,
"s:1"
,
proto
.
STORAGE
,
1
,
proto
.
RUNNING
,
0.01
))
tMC
.
Expect
(
node
(
"c"
,
""
,
proto
.
CLIENT
,
1
,
proto
.
RUNNING
,
0.02
))
tMC
.
Expect
(
δ
node
(
"c"
,
""
,
proto
.
CLIENT
,
1
,
proto
.
RUNNING
,
0.02
))
// ----------------------------------------
// ----------------------------------------
...
...
go/neo/neo_tracego_test.go
View file @
f5b60fb0
...
@@ -31,6 +31,8 @@ import (
...
@@ -31,6 +31,8 @@ import (
)
)
// TraceCollector connects to NEO-specific trace points via probes and sends events to dispatcher.
// TraceCollector connects to NEO-specific trace points via probes and sends events to dispatcher.
//
// XXX naming -> GoTracer (and PyTracer for NEO/py)
type
TraceCollector
struct
{
type
TraceCollector
struct
{
pg
*
tracing
.
ProbeGroup
pg
*
tracing
.
ProbeGroup
d
interface
{
Dispatch
(
interface
{})
}
d
interface
{
Dispatch
(
interface
{})
}
...
...
go/neo/proto/proto-misc.go
View file @
f5b60fb0
...
@@ -148,6 +148,7 @@ func (t IdTime) String() string {
...
@@ -148,6 +148,7 @@ func (t IdTime) String() string {
// ----------------------------------------
// ----------------------------------------
// Addr converts network address string into NEO Address
// Addr converts network address string into NEO Address
//
// TODO make neo.Address just string without host:port split
// TODO make neo.Address just string without host:port split
func
AddrString
(
network
,
addr
string
)
(
Address
,
error
)
{
func
AddrString
(
network
,
addr
string
)
(
Address
,
error
)
{
// empty is always empty
// empty is always empty
...
...
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