Commit 51dcbce3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent deb1984c
...@@ -125,7 +125,7 @@ func (p *RowInfo) NEOEncodedLen() int { ...@@ -125,7 +125,7 @@ func (p *RowInfo) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.CellList)) l := uint32(len(p.CellList))
size += 4 size += 8
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
_ = a _ = a
...@@ -370,7 +370,7 @@ func (p *AcceptIdentification) NEOEncodedLen() int { ...@@ -370,7 +370,7 @@ func (p *AcceptIdentification) NEOEncodedLen() int {
} }
{ {
l := uint32(len(p.KnownMasterList)) l := uint32(len(p.KnownMasterList))
size += 2 size += 6
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.KnownMasterList[i] a := &p.KnownMasterList[i]
{ {
...@@ -656,12 +656,12 @@ func (p *AnswerPartitionTable) NEOEncodedLen() int { ...@@ -656,12 +656,12 @@ func (p *AnswerPartitionTable) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.RowList)) l := uint32(len(p.RowList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := uint32(len((*a).CellList))
size += 4 size += 8
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
_ = a _ = a
...@@ -741,12 +741,12 @@ func (p *NotifyPartitionTable) NEOEncodedLen() int { ...@@ -741,12 +741,12 @@ func (p *NotifyPartitionTable) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.RowList)) l := uint32(len(p.RowList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := uint32(len((*a).CellList))
size += 4 size += 8
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
_ = a _ = a
...@@ -826,7 +826,7 @@ func (p *PartitionChanges) NEOEncodedLen() int { ...@@ -826,7 +826,7 @@ func (p *PartitionChanges) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.CellList)) l := uint32(len(p.CellList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
_ = a _ = a
...@@ -945,7 +945,7 @@ func (p *AnswerUnfinishedTransactions) NEOEncodedLen() int { ...@@ -945,7 +945,7 @@ func (p *AnswerUnfinishedTransactions) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.TidList)) l := uint32(len(p.TidList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
_ = a _ = a
...@@ -1173,7 +1173,7 @@ func (p *FinishTransaction) NEOEncodedLen() int { ...@@ -1173,7 +1173,7 @@ func (p *FinishTransaction) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.OIDList)) l := uint32(len(p.OIDList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OIDList[i] a := &p.OIDList[i]
_ = a _ = a
...@@ -1182,7 +1182,7 @@ func (p *FinishTransaction) NEOEncodedLen() int { ...@@ -1182,7 +1182,7 @@ func (p *FinishTransaction) NEOEncodedLen() int {
} }
{ {
l := uint32(len(p.CheckedList)) l := uint32(len(p.CheckedList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CheckedList[i] a := &p.CheckedList[i]
_ = a _ = a
...@@ -1346,7 +1346,7 @@ func (p *InvalidateObjects) NEOEncodedLen() int { ...@@ -1346,7 +1346,7 @@ func (p *InvalidateObjects) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.OidList)) l := uint32(len(p.OidList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
_ = a _ = a
...@@ -1440,7 +1440,7 @@ func (p *AnswerGenerateOIDs) NEOEncodedLen() int { ...@@ -1440,7 +1440,7 @@ func (p *AnswerGenerateOIDs) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.OidList)) l := uint32(len(p.OidList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
_ = a _ = a
...@@ -1490,7 +1490,7 @@ func (p *StoreObject) NEOEncodedLen() int { ...@@ -1490,7 +1490,7 @@ func (p *StoreObject) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.Data)) l := uint32(len(p.Data))
size += 37 size += 41
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
_ = a _ = a
...@@ -1650,7 +1650,7 @@ func (p *StoreTransaction) NEOEncodedLen() int { ...@@ -1650,7 +1650,7 @@ func (p *StoreTransaction) NEOEncodedLen() int {
} }
{ {
l := uint32(len(p.OidList)) l := uint32(len(p.OidList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
_ = a _ = a
...@@ -1796,7 +1796,7 @@ func (p *AnswerGetObject) NEOEncodedLen() int { ...@@ -1796,7 +1796,7 @@ func (p *AnswerGetObject) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.Data)) l := uint32(len(p.Data))
size += 45 size += 49
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
_ = a _ = a
...@@ -1921,7 +1921,7 @@ func (p *AnswerTIDList) NEOEncodedLen() int { ...@@ -1921,7 +1921,7 @@ func (p *AnswerTIDList) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.TIDList)) l := uint32(len(p.TIDList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TIDList[i] a := &p.TIDList[i]
_ = a _ = a
...@@ -1998,7 +1998,7 @@ func (p *AnswerTIDListFrom) NEOEncodedLen() int { ...@@ -1998,7 +1998,7 @@ func (p *AnswerTIDListFrom) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.TidList)) l := uint32(len(p.TidList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
_ = a _ = a
...@@ -2081,7 +2081,7 @@ func (p *AnswerTransactionInformation) NEOEncodedLen() int { ...@@ -2081,7 +2081,7 @@ func (p *AnswerTransactionInformation) NEOEncodedLen() int {
} }
{ {
l := uint32(len(p.OidList)) l := uint32(len(p.OidList))
size += 1 size += 5
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
_ = a _ = a
...@@ -2208,7 +2208,7 @@ func (p *AnswerObjectHistory) NEOEncodedLen() int { ...@@ -2208,7 +2208,7 @@ func (p *AnswerObjectHistory) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.HistoryList)) l := uint32(len(p.HistoryList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.HistoryList[i] a := &p.HistoryList[i]
_ = a _ = a
...@@ -2290,12 +2290,12 @@ func (p *AnswerPartitionList) NEOEncodedLen() int { ...@@ -2290,12 +2290,12 @@ func (p *AnswerPartitionList) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.RowList)) l := uint32(len(p.RowList))
size += 8 size += 12
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := uint32(len((*a).CellList))
size += 4 size += 8
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
_ = a _ = a
...@@ -2396,7 +2396,7 @@ func (p *AnswerNodeList) NEOEncodedLen() int { ...@@ -2396,7 +2396,7 @@ func (p *AnswerNodeList) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.NodeList)) l := uint32(len(p.NodeList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
{ {
...@@ -2497,7 +2497,7 @@ func (p *AddPendingNodes) NEOEncodedLen() int { ...@@ -2497,7 +2497,7 @@ func (p *AddPendingNodes) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.UUIDList)) l := uint32(len(p.UUIDList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
_ = a _ = a
...@@ -2547,7 +2547,7 @@ func (p *TweakPartitionTable) NEOEncodedLen() int { ...@@ -2547,7 +2547,7 @@ func (p *TweakPartitionTable) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.UUIDList)) l := uint32(len(p.UUIDList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
_ = a _ = a
...@@ -2597,7 +2597,7 @@ func (p *NotifyNodeInformation) NEOEncodedLen() int { ...@@ -2597,7 +2597,7 @@ func (p *NotifyNodeInformation) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.NodeList)) l := uint32(len(p.NodeList))
size += 0 size += 4
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
{ {
...@@ -2757,7 +2757,7 @@ func (p *ObjectUndoSerial) NEOEncodedLen() int { ...@@ -2757,7 +2757,7 @@ func (p *ObjectUndoSerial) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.OidList)) l := uint32(len(p.OidList))
size += 24 size += 28
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
_ = a _ = a
...@@ -3360,7 +3360,7 @@ func (p *PartitionCorrupted) NEOEncodedLen() int { ...@@ -3360,7 +3360,7 @@ func (p *PartitionCorrupted) NEOEncodedLen() int {
var size uint32 var size uint32
{ {
l := uint32(len(p.CellList)) l := uint32(len(p.CellList))
size += 4 size += 8
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
_ = a _ = a
......
...@@ -59,10 +59,16 @@ func TestPktHeader(t *testing.T) { ...@@ -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 // test marshalling for one packet type
func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) { func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) {
typ := reflect.TypeOf(pkt).Elem() // type of *pkt typ := reflect.TypeOf(pkt).Elem() // type of *pkt
pkt2 := reflect.New(typ).Interface().(NEODecoder) pkt2 := reflect.New(typ).Interface().(NEOCodec)
defer func() { defer func() {
if e := recover(); e != nil { if e := recover(); e != nil {
t.Errorf("%v: panic ↓↓↓:", typ) t.Errorf("%v: panic ↓↓↓:", typ)
...@@ -70,7 +76,14 @@ func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) { ...@@ -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 // check decoding
data := encoded + "noise" data := encoded + "noise"
...@@ -103,7 +116,7 @@ func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) { ...@@ -103,7 +116,7 @@ func testPktMarshal(t *testing.T, pkt NEODecoder, encoded string) {
// test encoding/decoding of packets // test encoding/decoding of packets
func TestPktMarshal(t *testing.T) { func TestPktMarshal(t *testing.T) {
var testv = []struct { var testv = []struct {
pkt NEODecoder //interface {NEOEncoder; NEODecoder} pkt NEOCodec
encoded string // []byte encoded string // []byte
} { } {
// empty // empty
......
...@@ -315,8 +315,8 @@ func (d *decoder) genStrBytes(assignto string) { ...@@ -315,8 +315,8 @@ func (d *decoder) genStrBytes(assignto string) {
func (e *encoder) genSlice(path string, typ *types.Slice, obj types.Object) { func (e *encoder) genSlice(path string, typ *types.Slice, obj types.Object) {
e.emit("{") e.emit("{")
e.emit("l := uint32(len(%s))", path) e.emit("l := uint32(len(%s))", path)
e.genBasic("l", types.Typ[types.Uint32], nil, nil)
if !e.SizeOnly { if !e.SizeOnly {
e.genBasic("l", types.Typ[types.Uint32], nil, nil)
e.emit("data = data[%v:]", e.n) e.emit("data = data[%v:]", e.n)
} else { } else {
e.emit("size += %v", e.n) e.emit("size += %v", e.n)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment