You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
883 B

  1. package mempool
  2. import (
  3. "context"
  4. abciclient "github.com/tendermint/tendermint/abci/client"
  5. "github.com/tendermint/tendermint/abci/example/kvstore"
  6. "github.com/tendermint/tendermint/config"
  7. "github.com/tendermint/tendermint/internal/mempool"
  8. "github.com/tendermint/tendermint/libs/log"
  9. )
  10. var mp *mempool.TxMempool
  11. var getMp func() mempool.Mempool
  12. func init() {
  13. app := kvstore.NewApplication()
  14. logger := log.NewNopLogger()
  15. conn := abciclient.NewLocalClient(logger, app)
  16. err := conn.Start(context.TODO())
  17. if err != nil {
  18. panic(err)
  19. }
  20. cfg := config.DefaultMempoolConfig()
  21. cfg.Broadcast = false
  22. getMp = func() mempool.Mempool {
  23. if mp == nil {
  24. mp = mempool.NewTxMempool(logger, cfg, conn)
  25. }
  26. return mp
  27. }
  28. }
  29. func Fuzz(data []byte) int {
  30. err := getMp().CheckTx(context.Background(), data, nil, mempool.TxInfo{})
  31. if err != nil {
  32. return 0
  33. }
  34. return 1
  35. }