Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update maxHeaderSize #1800 #1877

Merged
merged 8 commits into from Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions structs.go
Expand Up @@ -72,8 +72,8 @@ type header struct {

const (
// Maximum possible size of the header. The maximum size of header struct will be 18 but the
// maximum size of varint encoded header will be 21.
maxHeaderSize = 21
// maximum size of varint encoded header will be 22.
maxHeaderSize = 22
)

// Encode encodes the header into []byte. The provided []byte should be atleast 5 bytes. The
Expand Down
17 changes: 17 additions & 0 deletions structs_test.go
@@ -0,0 +1,17 @@
package badger

import (
"math"
"testing"

"github.com/stretchr/testify/require"
)

// Regression test for github.com/dgraph-io/badger/pull/1800
func TestLargeEncode(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the newline

var headerEnc [maxHeaderSize]byte
h := header{math.MaxUint32, math.MaxUint32, math.MaxUint64, math.MaxUint8, math.MaxUint8}
require.NotPanics(t, func() { _ = h.Encode(headerEnc[:]) })

mangalaman93 marked this conversation as resolved.
Show resolved Hide resolved
}