Commit 5168e32d authored by Jonathan Mace's avatar Jonathan Mace

Bug fix in keyed headers

parent d332db6b
......@@ -53,7 +53,7 @@ func MakeIndexedHeader(level int, index uint64) []byte {
}
func MakeKeyedHeader(level int, key []byte) []byte {
prefix := 0x80 | ((uint8(15 - level) << 3) & 0x78) | 0x02
prefix := 0x80 | ((uint8(15 - level) << 3) & 0x78) | 0x04
return append(append(make([]byte, 0, len(key)+1), prefix), key...)
}
......
......@@ -68,7 +68,7 @@ func TestInterpretHeaderAtoms(t *testing.T) {
func TestMakeHeaderAtom(t *testing.T) {
assert.Equal(t, []byte{248, 5}, MakeIndexedHeader(0, 5))
assert.Equal(t, []byte{240, 7}, MakeIndexedHeader(1, 7))
assert.Equal(t, []byte{250, 104, 105}, MakeKeyedHeader(0, []byte("hi")))
assert.Equal(t, []byte{242, 111, 107}, MakeKeyedHeader(1, []byte("ok")))
assert.Equal(t, []byte{252, 104, 105}, MakeKeyedHeader(0, []byte("hi")))
assert.Equal(t, []byte{244, 111, 107}, MakeKeyedHeader(1, []byte("ok")))
}
\ No newline at end of file
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