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.

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