Files
tendermint/test/fuzz/tests/mempool_test.go
elias-orijtech e741d01231 fuzz: don't panic on expected errors (#8423)
In the conversion to Go 1.18 fuzzing in e4991fd862,
a `return 0` was converted to a panic. A `return 0` is a hint to the fuzzer, not
a failing testcase.

While here, clean up the test by folding setup code into it.
2022-04-27 07:26:21 -07:00

34 lines
775 B
Go

//go:build gofuzz || go1.18
package tests
import (
"context"
"testing"
abciclient "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/internal/mempool"
"github.com/tendermint/tendermint/libs/log"
)
func FuzzMempool(f *testing.F) {
app := kvstore.NewApplication()
logger := log.NewNopLogger()
conn := abciclient.NewLocalClient(logger, app)
err := conn.Start(context.TODO())
if err != nil {
panic(err)
}
cfg := config.DefaultMempoolConfig()
cfg.Broadcast = false
mp := mempool.NewTxMempool(logger, cfg, conn)
f.Fuzz(func(t *testing.T, data []byte) {
_ = mp.CheckTx(context.Background(), data, nil, mempool.TxInfo{})
})
}