Skip to content

Commit

Permalink
test(x/interchainstaking/types): add a fuzzer for ParseMemoFields
Browse files Browse the repository at this point in the history
This change adds a fuzzer for ParseMemoFields; this change is in
anticipation of improving security and overall tests as we get ready
to put up this repository on oss-fuzz for continuous fuzzing.
  • Loading branch information
odeke-em committed May 1, 2024
1 parent 6d452b1 commit 7f6486b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions x/interchainstaking/types/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package types_test

import (
"testing"

"github.com/quicksilver-zone/quicksilver/x/interchainstaking/types"
)

func FuzzParseMemoFields(f *testing.F) {
if testing.Short() {
f.Skip("In -short mode")
}

// 1. Add the corpa seeds.
seeds := [][]byte{
// Valid sequences.
{
byte(types.FieldTypeAccountMap), 2, 1, 1,
},
{
byte(types.FieldTypeAccountMap), 2, 1, 1,
byte(types.FieldTypeReturnToSender), 0,
},

// Invalid sequences.
{
3, 2, 1, 1,
byte(types.FieldTypeReturnToSender), 0,
},
{
byte(types.FieldTypeAccountMap), 0,
byte(types.FieldTypeReturnToSender), 0,
},
{
byte(types.FieldTypeAccountMap), 3, 0, 0,
byte(types.FieldTypeReturnToSender), 4, 1, 1, 1, 3,
},
{byte(types.FieldTypeAccountMap), 1, 0, 0},
}

for _, seed := range seeds {
f.Add(seed)
}

// 2. Now run the fuzzers.
f.Fuzz(func(t *testing.T, input []byte) {
_, _ = types.ParseMemoFields(input)
})
}

0 comments on commit 7f6486b

Please sign in to comment.