//go:build gofuzz || go1.21

package tests

import (
	"testing"

	abciclient "git.cw.tr/mukan-network/mukan-consensus/abci/client"
	"git.cw.tr/mukan-network/mukan-consensus/abci/example/kvstore"
	"git.cw.tr/mukan-network/mukan-consensus/config"
	cmtsync "git.cw.tr/mukan-network/mukan-consensus/libs/sync"
	mempool "git.cw.tr/mukan-network/mukan-consensus/mempool"
)

func FuzzMempool(f *testing.F) {
	app := kvstore.NewInMemoryApplication()
	mtx := new(cmtsync.Mutex)
	conn := abciclient.NewLocalClient(mtx, app)
	err := conn.Start()
	if err != nil {
		panic(err)
	}

	cfg := config.DefaultMempoolConfig()
	cfg.Broadcast = false

	mp := mempool.NewCListMempool(cfg, conn, 0)

	f.Fuzz(func(t *testing.T, data []byte) {
		_ = mp.CheckTx(data, nil, mempool.TxInfo{})
	})
}
