Commit 47999e52 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 30bc8903
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// //
// See COPYING file for full licensing terms. // See COPYING file for full licensing terms.
// NEO. Protocol definition. Tests // NEO. Protocol. Tests
package neo package neo
...@@ -80,7 +80,7 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) { ...@@ -80,7 +80,7 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) {
} }
}() }()
// check encoding // pkt.encode() == expected
n := pkt.NEOEncodedLen() n := pkt.NEOEncodedLen()
if n != len(encoded) { if n != len(encoded) {
t.Errorf("%v: encodedLen = %v ; want %v", typ, n, len(encoded)) t.Errorf("%v: encodedLen = %v ; want %v", typ, n, len(encoded))
...@@ -121,9 +121,9 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) { ...@@ -121,9 +121,9 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) {
}() }()
} }
// check decoding // pkt.decode() == expected
data := encoded + "noise" data := []byte(encoded + "noise")
n, err := pkt2.NEODecode([]byte(data)) // XXX n, err := pkt2.NEODecode(data)
if err != nil { if err != nil {
t.Errorf("%v: decode error %v", typ, err) t.Errorf("%v: decode error %v", typ, err)
} }
...@@ -135,18 +135,14 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) { ...@@ -135,18 +135,14 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) {
t.Errorf("%v: decode result unexpected: %v ; want %v", typ, pkt2, pkt) t.Errorf("%v: decode result unexpected: %v ; want %v", typ, pkt2, pkt)
} }
// decode must overflow on cut data TODO reenable // decode must detect buffer overflow
/*
for l := len(encoded)-1; l >= 0; l-- { for l := len(encoded)-1; l >= 0; l-- {
// NOTE cap must not be > l n, err = pkt2.NEODecode(data[:l])
data = encoded[:l] // XXX also check on original byte [:l] ?
n, err = pkt2.NEODecode([]byte(data)) // XXX
if !(n==0 && err==ErrDecodeOverflow) { if !(n==0 && err==ErrDecodeOverflow) {
t.Errorf("%v: decode overflow not detected on [:%v]", typ, l) t.Errorf("%v: decode overflow not detected on [:%v]", typ, l)
} }
} }
*/
} }
// test encoding/decoding of packets // test encoding/decoding of packets
......
...@@ -194,7 +194,7 @@ func typeSizeFixed(typ types.Type) (wireSize int, ok bool) { ...@@ -194,7 +194,7 @@ func typeSizeFixed(typ types.Type) (wireSize int, ok bool) {
} }
notfixed: notfixed:
// not matched above - not fixed // everything else is of not fixed wire size
return 0, false return 0, false
} }
......
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