mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-11 07:20:19 +00:00
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.
34 lines
775 B
Go
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{})
|
|
})
|
|
}
|