Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
ce6c0ff3
Commit
ce6c0ff3
authored
Jun 07, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0c886069
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
35 deletions
+15
-35
go/neo/cluster_test.go
go/neo/cluster_test.go
+11
-11
go/neo/proto.go
go/neo/proto.go
+0
-20
go/neo/proto_test.go
go/neo/proto_test.go
+4
-4
No files found.
go/neo/cluster_test.go
View file @
ce6c0ff3
...
...
@@ -15,7 +15,7 @@
//
// See COPYING file for full licensing terms.
package
neo
package
neo
_test
// test interaction between nodes
import
(
...
...
@@ -25,6 +25,10 @@ import (
"reflect"
"testing"
.
"../neo"
"../neo/client"
"../neo/server"
"../zodb"
"../zodb/storage/fs1"
...
...
@@ -32,24 +36,20 @@ import (
)
// xfs1stor creates new NEO storage node backed by fs1
// XXX is this wrapper a good idea?
func
xfs1stor
(
net
Network
,
path
string
)
(
*
Storage
,
*
fs1
.
FileStorage
)
{
func
xfs1stor
(
net
Network
,
path
string
)
(
*
server
.
Storage
,
*
fs1
.
FileStorage
)
{
// TODO +readonly ?
zstor
,
err
:=
fs1
.
Open
(
context
.
Background
(),
path
)
exc
.
Raiseif
(
err
)
return
NewStorage
(
"test cluster"
,
"TODO master"
,
""
,
net
,
zstor
),
zstor
return
server
.
NewStorage
(
"test cluster"
,
"TODO master"
,
""
,
net
,
zstor
),
zstor
}
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown
func
TestMasterStorage
(
t
*
testing
.
T
)
{
net
:=
NetPipe
(
""
)
// test network FIXME New registers to global table
M
:=
NewMaster
(
"abc1"
)
M
:=
server
.
NewMaster
(
"abc1"
)
S
,
_
:=
xfs1stor
(
net
,
"../zodb/storage/fs1/testdata/1.fs"
)
// XXX +readonly
Mctx
,
Mcancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
@@ -59,8 +59,8 @@ func TestMasterStorage(t *testing.T) {
Sbind
:=
""
;
Mbind
:=
""
;
var
err
error
_
=
Scancel
;
_
=
Mcancel
;
_
=
err
err
=
ListenAndServe
(
Mctx
,
net
,
Mbind
,
M
)
// XXX go
err
=
ListenAndServe
(
Sctx
,
net
,
Sbind
,
S
)
// XXX go
err
=
server
.
ListenAndServe
(
Mctx
,
net
,
Mbind
,
M
)
// XXX go
err
=
server
.
ListenAndServe
(
Sctx
,
net
,
Sbind
,
S
)
// XXX go
}
// basic interaction between Client -- Storage
...
...
@@ -77,7 +77,7 @@ func TestClientStorage(t *testing.T) {
// XXX + test error return
})
C
,
err
:=
NewClient
(
Cnl
)
C
,
err
:=
client
.
NewClient
(
Cnl
)
if
err
!=
nil
{
t
.
Fatalf
(
"creating/identifying client: %v"
,
err
)
}
...
...
go/neo/proto.go
View file @
ce6c0ff3
...
...
@@ -140,7 +140,6 @@ type NodeUUID int32
var
ErrDecodeOverflow
=
errors
.
New
(
"decode: bufer overflow"
)
// Pkt is the interface implemented by NEO packets to marshal/unmarshal them into/from wire format
// XXX -> will be neo.Pkt after splitting into packages
type
Pkt
interface
{
// NEOPktMsgCode returns message code needed to be used for particular packet type
// on the wire
...
...
@@ -157,25 +156,6 @@ type Pkt interface {
NEOPktDecode
(
data
[]
byte
)
(
nread
int
,
err
error
)
}
/*
// XXX do we need to keep it splitted as encoder/decoder ?
// NEOPktDecoder is the interface implemented by packets to unmarshal them from wire format
type NEOPktDecoder interface {
// NEOPktMsgCode returns message code that must have been used on the wire for this packet
NEOPktMsgCode() uint16
}
// NEOPkt is interface combining NEOPktEncoder & NEOPktDecoder
// in particular it covers all NEO packets
type NEOPkt interface {
NEOPktEncoder
NEOPktDecoder
// XXX is in both encoder and decoder
NEOPktMsgCode() uint16
}
*/
type
Address
struct
{
Host
string
...
...
go/neo/proto_test.go
View file @
ce6c0ff3
...
...
@@ -69,9 +69,9 @@ func TestPktHeader(t *testing.T) {
}
// test marshalling for one packet type
func
testPktMarshal
(
t
*
testing
.
T
,
pkt
NEO
Pkt
,
encoded
string
)
{
func
testPktMarshal
(
t
*
testing
.
T
,
pkt
Pkt
,
encoded
string
)
{
typ
:=
reflect
.
TypeOf
(
pkt
)
.
Elem
()
// type of *pkt
pkt2
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
NEO
Pkt
)
pkt2
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
Pkt
)
defer
func
()
{
if
e
:=
recover
();
e
!=
nil
{
t
.
Errorf
(
"%v: panic ↓↓↓:"
,
typ
)
...
...
@@ -152,7 +152,7 @@ func testPktMarshal(t *testing.T, pkt NEOPkt, encoded string) {
// test encoding/decoding of packets
func
TestPktMarshal
(
t
*
testing
.
T
)
{
var
testv
=
[]
struct
{
pkt
NEO
Pkt
pkt
Pkt
encoded
string
// []byte
}
{
// empty
...
...
@@ -268,7 +268,7 @@ func TestPktMarshal(t *testing.T) {
func
TestPktMarshalAllOverflowLightly
(
t
*
testing
.
T
)
{
for
_
,
typ
:=
range
pktTypeRegistry
{
// zero-value for a type
pkt
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
NEO
Pkt
)
pkt
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
Pkt
)
l
:=
pkt
.
NEOPktEncodedLen
()
zerol
:=
make
([]
byte
,
l
)
// decoding will turn nil slice & map into empty allocated ones.
...
...
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