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.

110 lines
2.2 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. TMHOME="$HOME/.tendermint"
  12. rm -rf "$TMHOME"
  13. cp -r "$DIR_TO_COPY" "$TMHOME"
  14. cp $TMHOME/config.toml $TMHOME/config.toml.bak
  15. function reset(){
  16. tendermint unsafe_reset_all
  17. cp $TMHOME/config.toml.bak $TMHOME/config.toml
  18. }
  19. reset
  20. # empty block
  21. function empty_block(){
  22. tendermint node --proxy_app=persistent_dummy &> /dev/null &
  23. sleep 5
  24. killall tendermint
  25. # /q would print up to and including the match, then quit.
  26. # /Q doesn't include the match.
  27. # http://unix.stackexchange.com/questions/11305/grep-show-all-the-file-up-to-the-match
  28. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/empty_block.cswal
  29. reset
  30. }
  31. # many blocks
  32. function many_blocks(){
  33. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  34. PID=$!
  35. tendermint node --proxy_app=persistent_dummy &> /dev/null &
  36. sleep 7
  37. killall tendermint
  38. kill -9 $PID
  39. sed '/ENDHEIGHT: 6/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/many_blocks.cswal
  40. reset
  41. }
  42. # small block 1
  43. function small_block1(){
  44. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  45. PID=$!
  46. tendermint node --proxy_app=persistent_dummy &> /dev/null &
  47. sleep 10
  48. killall tendermint
  49. kill -9 $PID
  50. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/small_block1.cswal
  51. reset
  52. }
  53. # small block 2 (part size = 512)
  54. function small_block2(){
  55. echo "" >> ~/.tendermint/config.toml
  56. echo "block_part_size = 512" >> ~/.tendermint/config.toml
  57. bash scripts/txs/random.sh 1000 36657 &> /dev/null &
  58. PID=$!
  59. tendermint node --proxy_app=persistent_dummy &> /dev/null &
  60. sleep 5
  61. killall tendermint
  62. kill -9 $PID
  63. sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/small_block2.cswal
  64. reset
  65. }
  66. case "$1" in
  67. "small_block1")
  68. small_block1
  69. ;;
  70. "small_block2")
  71. small_block2
  72. ;;
  73. "empty_block")
  74. empty_block
  75. ;;
  76. "many_blocks")
  77. many_blocks
  78. ;;
  79. *)
  80. small_block1
  81. small_block2
  82. empty_block
  83. many_blocks
  84. esac