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
51dcbce3
Commit
51dcbce3
authored
Jan 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
deb1984c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
32 deletions
+45
-32
t/neo/marshal.go
t/neo/marshal.go
+27
-27
t/neo/proto_test.go
t/neo/proto_test.go
+17
-4
t/neo/protogen.go
t/neo/protogen.go
+1
-1
No files found.
t/neo/marshal.go
View file @
51dcbce3
...
...
@@ -125,7 +125,7 @@ func (p *RowInfo) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
CellList
))
size
+=
4
size
+=
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
CellList
[
i
]
_
=
a
...
...
@@ -370,7 +370,7 @@ func (p *AcceptIdentification) NEOEncodedLen() int {
}
{
l
:=
uint32
(
len
(
p
.
KnownMasterList
))
size
+=
2
size
+=
6
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
KnownMasterList
[
i
]
{
...
...
@@ -656,12 +656,12 @@ func (p *AnswerPartitionTable) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
RowList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
RowList
[
i
]
{
l
:=
uint32
(
len
((
*
a
)
.
CellList
))
size
+=
4
size
+=
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
(
*
a
)
.
CellList
[
i
]
_
=
a
...
...
@@ -741,12 +741,12 @@ func (p *NotifyPartitionTable) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
RowList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
RowList
[
i
]
{
l
:=
uint32
(
len
((
*
a
)
.
CellList
))
size
+=
4
size
+=
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
(
*
a
)
.
CellList
[
i
]
_
=
a
...
...
@@ -826,7 +826,7 @@ func (p *PartitionChanges) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
CellList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
CellList
[
i
]
_
=
a
...
...
@@ -945,7 +945,7 @@ func (p *AnswerUnfinishedTransactions) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
TidList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TidList
[
i
]
_
=
a
...
...
@@ -1173,7 +1173,7 @@ func (p *FinishTransaction) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
OIDList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OIDList
[
i
]
_
=
a
...
...
@@ -1182,7 +1182,7 @@ func (p *FinishTransaction) NEOEncodedLen() int {
}
{
l
:=
uint32
(
len
(
p
.
CheckedList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
CheckedList
[
i
]
_
=
a
...
...
@@ -1346,7 +1346,7 @@ func (p *InvalidateObjects) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
OidList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
_
=
a
...
...
@@ -1440,7 +1440,7 @@ func (p *AnswerGenerateOIDs) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
OidList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
_
=
a
...
...
@@ -1490,7 +1490,7 @@ func (p *StoreObject) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
Data
))
size
+=
37
size
+=
41
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
Data
[
i
]
_
=
a
...
...
@@ -1650,7 +1650,7 @@ func (p *StoreTransaction) NEOEncodedLen() int {
}
{
l
:=
uint32
(
len
(
p
.
OidList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
_
=
a
...
...
@@ -1796,7 +1796,7 @@ func (p *AnswerGetObject) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
Data
))
size
+=
4
5
size
+=
4
9
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
Data
[
i
]
_
=
a
...
...
@@ -1921,7 +1921,7 @@ func (p *AnswerTIDList) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
TIDList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TIDList
[
i
]
_
=
a
...
...
@@ -1998,7 +1998,7 @@ func (p *AnswerTIDListFrom) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
TidList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TidList
[
i
]
_
=
a
...
...
@@ -2081,7 +2081,7 @@ func (p *AnswerTransactionInformation) NEOEncodedLen() int {
}
{
l
:=
uint32
(
len
(
p
.
OidList
))
size
+=
1
size
+=
5
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
_
=
a
...
...
@@ -2208,7 +2208,7 @@ func (p *AnswerObjectHistory) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
HistoryList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
HistoryList
[
i
]
_
=
a
...
...
@@ -2290,12 +2290,12 @@ func (p *AnswerPartitionList) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
RowList
))
size
+=
8
size
+=
12
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
RowList
[
i
]
{
l
:=
uint32
(
len
((
*
a
)
.
CellList
))
size
+=
4
size
+=
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
(
*
a
)
.
CellList
[
i
]
_
=
a
...
...
@@ -2396,7 +2396,7 @@ func (p *AnswerNodeList) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
NodeList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
NodeList
[
i
]
{
...
...
@@ -2497,7 +2497,7 @@ func (p *AddPendingNodes) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
UUIDList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
UUIDList
[
i
]
_
=
a
...
...
@@ -2547,7 +2547,7 @@ func (p *TweakPartitionTable) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
UUIDList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
UUIDList
[
i
]
_
=
a
...
...
@@ -2597,7 +2597,7 @@ func (p *NotifyNodeInformation) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
NodeList
))
size
+=
0
size
+=
4
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
NodeList
[
i
]
{
...
...
@@ -2757,7 +2757,7 @@ func (p *ObjectUndoSerial) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
OidList
))
size
+=
2
4
size
+=
2
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
_
=
a
...
...
@@ -3360,7 +3360,7 @@ func (p *PartitionCorrupted) NEOEncodedLen() int {
var
size
uint32
{
l
:=
uint32
(
len
(
p
.
CellList
))
size
+=
4
size
+=
8
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
CellList
[
i
]
_
=
a
...
...
t/neo/proto_test.go
View file @
51dcbce3
...
...
@@ -59,10 +59,16 @@ func TestPktHeader(t *testing.T) {
}
}
// XXX move me out of here?
type
NEOCodec
interface
{
NEOEncoder
NEODecoder
}
// test marshalling for one packet type
func
testPktMarshal
(
t
*
testing
.
T
,
pkt
NEO
Decoder
,
encoded
string
)
{
func
testPktMarshal
(
t
*
testing
.
T
,
pkt
NEO
Codec
,
encoded
string
)
{
typ
:=
reflect
.
TypeOf
(
pkt
)
.
Elem
()
// type of *pkt
pkt2
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
NEO
Decoder
)
pkt2
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
NEO
Codec
)
defer
func
()
{
if
e
:=
recover
();
e
!=
nil
{
t
.
Errorf
(
"%v: panic ↓↓↓:"
,
typ
)
...
...
@@ -70,7 +76,14 @@ func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) {
}
}()
// TODO check encoding
// check encoding
n
:=
pkt
.
NEOEncodedLen
()
if
n
!=
len
(
encoded
)
{
t
.
Errorf
(
"%v: encodedLen = %v ; want %v"
,
typ
,
n
,
len
(
encoded
))
}
// TODO encode - check == encoded
// TODO encode(smaller buf) -> panic
// check decoding
data
:=
encoded
+
"noise"
...
...
@@ -103,7 +116,7 @@ func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) {
// test encoding/decoding of packets
func
TestPktMarshal
(
t
*
testing
.
T
)
{
var
testv
=
[]
struct
{
pkt
NEO
Decoder
//interface {NEOEncoder; NEODecoder}
pkt
NEO
Codec
encoded
string
// []byte
}
{
// empty
...
...
t/neo/protogen.go
View file @
51dcbce3
...
...
@@ -315,8 +315,8 @@ func (d *decoder) genStrBytes(assignto string) {
func
(
e
*
encoder
)
genSlice
(
path
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
e
.
emit
(
"{"
)
e
.
emit
(
"l := uint32(len(%s))"
,
path
)
e
.
genBasic
(
"l"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
if
!
e
.
SizeOnly
{
e
.
genBasic
(
"l"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
}
else
{
e
.
emit
(
"size += %v"
,
e
.
n
)
...
...
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