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.

108 lines
2.1 KiB

  1. #!/usr/bin/env bash
  2. # XXX: removes tendermint dir
  3. cd "$GOPATH/src/github.com/tendermint/tendermint" || exit 1
  4. # Make sure we have a tendermint command.
  5. if ! hash tendermint 2>/dev/null; then
  6. make install
  7. fi
  8. # specify a dir to copy
  9. # TODO: eventually we should replace with `tendermint init --test`
  10. DIR_TO_COPY=$HOME/.tendermint_test/consensus_state_test
  11. rm -rf "$HOME/.tendermint"
  12. cp -r "$DIR_TO_COPY" "$HOME/.tendermint"
  13. function reset(){
  14. rm -rf "$HOME/.tendermint/data"
  15. tendermint unsafe_reset_priv_validator
  16. }
  17. reset
  18. # empty block
  19. function empty_block(){
  20. tendermint node --proxy_app=dummy &> /dev/null &
  21. sleep 5
  22. killall tendermint
  23. # /q would print up to and including the match, then quit.
  24. # /Q doesn't include the match.
  25. # http://unix.stackexchange.com/questions/11305/grep-show-all-the-file-up-to-the-match
  26. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/empty_block.cswal
  27. reset
  28. }
  29. # many blocks
  30. function many_blocks(){
  31. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  32. PID=$!
  33. tendermint node --proxy_app=dummy &> /dev/null &
  34. sleep 7
  35. killall tendermint
  36. kill -9 $PID
  37. sed '/ENDHEIGHT: 6/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/many_blocks.cswal
  38. reset
  39. }
  40. # small block 1
  41. function small_block1(){
  42. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  43. PID=$!
  44. tendermint node --proxy_app=dummy &> /dev/null &
  45. sleep 10
  46. killall tendermint
  47. kill -9 $PID
  48. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/small_block1.cswal
  49. reset
  50. }
  51. # small block 2 (part size = 512)
  52. function small_block2(){
  53. echo "" >> ~/.tendermint/config.toml
  54. echo "block_part_size = 512" >> ~/.tendermint/config.toml
  55. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  56. PID=$!
  57. tendermint node --proxy_app=dummy &> /dev/null &
  58. sleep 5
  59. killall tendermint
  60. kill -9 $PID
  61. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/small_block2.cswal
  62. reset
  63. }
  64. case "$1" in
  65. "small_block1")
  66. small_block1
  67. ;;
  68. "small_block2")
  69. small_block2
  70. ;;
  71. "empty_block")
  72. empty_block
  73. ;;
  74. "many_blocks")
  75. many_blocks
  76. ;;
  77. *)
  78. small_block1
  79. small_block2
  80. empty_block
  81. many_blocks
  82. esac