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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
71c356e4
Commit
71c356e4
authored
Jan 17, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c298adbd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
105 deletions
+140
-105
t/neo/proto.go
t/neo/proto.go
+101
-101
t/neo/proto_test.go
t/neo/proto_test.go
+39
-4
No files found.
t/neo/proto.go
View file @
71c356e4
t/neo/proto_test.go
View file @
71c356e4
...
@@ -16,6 +16,7 @@ package neo
...
@@ -16,6 +16,7 @@ package neo
import
(
import
(
hexpkg
"encoding/hex"
hexpkg
"encoding/hex"
"encoding/binary"
"reflect"
"reflect"
"testing"
"testing"
"unsafe"
"unsafe"
...
@@ -30,6 +31,20 @@ func hex(s string) string {
...
@@ -30,6 +31,20 @@ func hex(s string) string {
return
string
(
b
)
return
string
(
b
)
}
}
// uint32 -> string as encoded on the wire
func
u32
(
v
uint32
)
string
{
var
b
[
4
]
byte
binary
.
BigEndian
.
PutUint32
(
b
[
:
],
v
)
return
string
(
b
[
:
])
}
// uint64 -> string as encoded on the wire
func
u64
(
v
uint64
)
string
{
var
b
[
8
]
byte
binary
.
BigEndian
.
PutUint64
(
b
[
:
],
v
)
return
string
(
b
[
:
])
}
func
TestPktHeader
(
t
*
testing
.
T
)
{
func
TestPktHeader
(
t
*
testing
.
T
)
{
// make sure PktHeader is really packed
// make sure PktHeader is really packed
if
unsafe
.
Sizeof
(
PktHead
{})
!=
10
{
if
unsafe
.
Sizeof
(
PktHead
{})
!=
10
{
...
@@ -86,7 +101,7 @@ func TestPktMarshal(t *testing.T) {
...
@@ -86,7 +101,7 @@ func TestPktMarshal(t *testing.T) {
// empty
// empty
{
&
Ping
{},
""
},
{
&
Ping
{},
""
},
// uint32, string
XXX string -> Notify?
// uint32, string
{
&
Error
{
Code
:
0x01020304
,
Message
:
"hello"
},
"
\x01\x02\x03\x04\x00\x00\x00\x05
hello"
},
{
&
Error
{
Code
:
0x01020304
,
Message
:
"hello"
},
"
\x01\x02\x03\x04\x00\x00\x00\x05
hello"
},
// Oid, Tid, bool, Checksum, []byte
// Oid, Tid, bool, Checksum, []byte
...
@@ -106,7 +121,7 @@ func TestPktMarshal(t *testing.T) {
...
@@ -106,7 +121,7 @@ func TestPktMarshal(t *testing.T) {
hex
(
"0000000b"
)
+
"hello world"
+
hex
(
"0000000b"
)
+
"hello world"
+
hex
(
"0a0b0c0d0e0f01030a0b0c0d0e0f010401"
)},
hex
(
"0a0b0c0d0e0f01030a0b0c0d0e0f010401"
)},
// PTid, [] (of [] of
...
)
// PTid, [] (of [] of
{UUID, CellState}
)
{
&
AnswerPartitionTable
{
{
&
AnswerPartitionTable
{
PTid
:
0x0102030405060708
,
PTid
:
0x0102030405060708
,
RowList
:
[]
RowInfo
{
RowList
:
[]
RowInfo
{
...
@@ -123,14 +138,34 @@ func TestPktMarshal(t *testing.T) {
...
@@ -123,14 +138,34 @@ func TestPktMarshal(t *testing.T) {
hex
(
"00000007000000030000000b000000040000000f000000030000001700000000"
),
hex
(
"00000007000000030000000b000000040000000f000000030000001700000000"
),
},
},
// map[Oid]struct {Tid,Tid,bool}
{
&
AnswerObjectUndoSerial
{
ObjectTIDDict
:
map
[
Oid
]
struct
{
CurrentSerial
Tid
UndoSerial
Tid
IsCurrent
bool
}
{
1
:
{
1
,
0
,
false
},
2
:
{
7
,
1
,
true
},
8
:
{
7
,
1
,
false
},
5
:
{
4
,
3
,
true
},
}},
u32
(
4
)
+
u64
(
1
)
+
u64
(
1
)
+
u64
(
0
)
+
hex
(
"00"
)
+
u64
(
2
)
+
u64
(
7
)
+
u64
(
1
)
+
hex
(
"01"
)
+
u64
(
8
)
+
u64
(
7
)
+
u64
(
1
)
+
hex
(
"00"
)
+
u64
(
5
)
+
u64
(
4
)
+
u64
(
3
)
+
hex
(
"01"
),
},
/*
/*
// uint32, Address, string, float64
// uint32, Address, string, float64
{&RequestIdentification{...}}, // TODO
{&RequestIdentification{...}}, // TODO
*/
*/
// TODO float64 (+ nan !nan ...)
// TODO float64 (+ nan !nan ...)
// TODO
[](!byte), map
// TODO
map <- AnswerLockedTransactions, AnswerObjectUndoSerial, CheckReplicas
// TODO Address,
PTid
// TODO Address,
}
}
for
_
,
tt
:=
range
testv
{
for
_
,
tt
:=
range
testv
{
...
...
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