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

keyformat, internal: add fuzzers #762

Closed
wants to merge 1 commit into from

Conversation

@odeke-em odeke-em requested a review from a team as a code owner May 4, 2023 21:23
Comment on lines +8 to +28
func TestRandStrHuge(t *testing.T) {
_ = RandStr(8455134228352958140)
}

func FuzzRandStr(f *testing.F) {
// 1. Seed the fuzzer with lengths.
mr := mrand.New(mrand.NewSource(10))
for i := 0; i < 100; i++ {
f.Add(mr.Int())
}

// 2. Now run the fuzzer.
rr := NewRand()
f.Fuzz(func(t *testing.T, n int) {
s := rr.Str(n)
// Ensure that we've got alphanumeric sequences entirely.
for _, c := range s {
switch {
case c >= '0' && c <= '9':
case c >= 'a' && c <= 'z':
case c >= 'A' && c <= 'Z':
Copy link
Member

Choose a reason for hiding this comment

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

please delete, we dont need to fuzz test helpers

Copy link
Member

Choose a reason for hiding this comment

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

ping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll remove it.

Adds fuzzers that have discovered some bugs, like:
* cosmos#760
* cosmos#761
@odeke-em odeke-em force-pushed the rand+keyformat-fuzzers branch from 16b2434 to 7e46b88 Compare May 24, 2023 00:26
@odeke-em
Copy link
Contributor Author

Closing this PR since RandStr is deemed to be an internal function only used in tests.

@odeke-em odeke-em closed this May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants