-
Notifications
You must be signed in to change notification settings - Fork 187
Add fuzz test for CellUnion #193
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
base: master
Are you sure you want to change the base?
Conversation
And jointly fixing panic that can happen for bad input. Slice creation with n < 0 panics.
@@ -553,7 +553,7 @@ func (cu *CellUnion) encode(e *encoder) { | |||
} | |||
} | |||
|
|||
// Decode decodes the CellUnion. | |||
// Decode decodes the CellUnion. The resulting CellUnion is not check for validity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "is not checked"
Probably clearer to explicitly mentionIsValid
though.
@@ -570,7 +570,7 @@ func (cu *CellUnion) decode(d *decoder) { | |||
return | |||
} | |||
n := d.readInt64() | |||
if d.err != nil { | |||
if d.err != nil || n < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do C++/Java do? Should this be read as uint64 / should the error be updated like below?
|
||
func FuzzDecodeCellUnion(f *testing.F) { | ||
cuCells := CellUnion([]CellID{ | ||
CellID(0x33), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these cells matter at all? How were they generated?
// Construction failed, no need to test further. | ||
return | ||
} | ||
if got := c.ApproxArea(); got < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you testing 0 but not 4 pi? What if the union isn't valid?
And jointly fixing panic that can happen for bad input. Slice creation with n < 0 panics. Starting point for #175