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.

48 lines
898 B

  1. // nolint: gosec
  2. package main
  3. import (
  4. "flag"
  5. "fmt"
  6. "io/ioutil"
  7. "log"
  8. "os"
  9. "path/filepath"
  10. )
  11. func main() {
  12. baseDir := flag.String("base", ".", `where the "corpus" directory will live`)
  13. flag.Parse()
  14. initCorpus(*baseDir)
  15. }
  16. func initCorpus(baseDir string) {
  17. log.SetFlags(0)
  18. corpusDir := filepath.Join(baseDir, "corpus")
  19. if err := os.MkdirAll(corpusDir, 0755); err != nil {
  20. log.Fatal(err)
  21. }
  22. data := []string{
  23. "dadc04c2-cfb1-4aa9-a92a-c0bf780ec8b6",
  24. "",
  25. " ",
  26. " a ",
  27. `{"a": 12, "tsp": 999, k: "blue"}`,
  28. `9999.999`,
  29. `""`,
  30. `Tendermint fuzzing`,
  31. }
  32. for i, datum := range data {
  33. filename := filepath.Join(corpusDir, fmt.Sprintf("%d", i))
  34. if err := ioutil.WriteFile(filename, []byte(datum), 0644); err != nil {
  35. log.Fatalf("can't write %v to %q: %v", datum, filename, err)
  36. }
  37. log.Printf("wrote %q", filename)
  38. }
  39. }