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.

49 lines
903 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. cc := abciclient.NewLocalCreator(app)
  15. appConnMem, _ := cc()
  16. err := appConnMem.Start()
  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(
  25. log.NewNopLogger(),
  26. cfg,
  27. appConnMem,
  28. 0,
  29. )
  30. }
  31. return mp
  32. }
  33. }
  34. func Fuzz(data []byte) int {
  35. err := getMp().CheckTx(context.Background(), data, nil, mempool.TxInfo{})
  36. if err != nil {
  37. return 0
  38. }
  39. return 1
  40. }