Commit 69e892b1 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Kamil Kisiel

tests: Fix BenchmarkDecode

After 2c359fc1 (decoder: Remember protocol version as last seen in a
PROTO opcode) BenchmarkDecode started to fail with

    --- FAIL: BenchmarkDecode
        ogorek_test.go:977: invalid pickle version

That happens because some input pickles now come with `PROTO 0xff`
prefix and version 0xff is indeed invalid.

-> Fix it by adjusting that prefix to be `PROTO 3` during benchmark as 3
is the most-widely used protocol version used by both py3 and py2 (via
zodbpickle).
parent 1b57c3e4
...@@ -967,8 +967,13 @@ func BenchmarkDecode(b *testing.B) { ...@@ -967,8 +967,13 @@ func BenchmarkDecode(b *testing.B) {
continue continue
} }
// not prepending `PROTO <ver>` - decoder should be // not prepending `PROTO <ver>` - decoder should be
// able to decode without it. // able to decode without it. But if the pickle already
input = append(input, pickle.data...) // comes with `PROTO 0xff` change it to `PROTO 3`.
data := pickle.data
if strings.HasPrefix(data, protoPrefixTemplate) {
data = string([]byte{opProto, 3}) + data[len(protoPrefixTemplate):]
}
input = append(input, data...)
npickle++ npickle++
} }
} }
......
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