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.

70 lines
1.4 KiB

  1. #! /bin/bash
  2. export TMHOME=$HOME/.tendermint_persist
  3. rm -rf $TMHOME
  4. tendermint init
  5. function start_procs(){
  6. name=$1
  7. echo "Starting persistent kvstore and tendermint"
  8. abci-cli kvstore --persist $TMHOME/kvstore &> "kvstore_${name}.log" &
  9. PID_DUMMY=$!
  10. tendermint node &> tendermint_${name}.log &
  11. PID_TENDERMINT=$!
  12. sleep 5
  13. }
  14. function kill_procs(){
  15. kill -9 $PID_DUMMY $PID_TENDERMINT
  16. }
  17. function send_txs(){
  18. # send a bunch of txs over a few blocks
  19. echo "Sending txs"
  20. for i in `seq 1 5`; do
  21. for j in `seq 1 100`; do
  22. tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'`
  23. curl -s 127.0.0.1:26657/broadcast_tx_async?tx=0x$tx &> /dev/null
  24. done
  25. sleep 1
  26. done
  27. }
  28. start_procs 1
  29. send_txs
  30. kill_procs
  31. start_procs 2
  32. # wait for node to handshake and make a new block
  33. addr="localhost:26657"
  34. curl -s $addr/status > /dev/null
  35. ERR=$?
  36. i=0
  37. while [ "$ERR" != 0 ]; do
  38. sleep 1
  39. curl -s $addr/status > /dev/null
  40. ERR=$?
  41. i=$(($i + 1))
  42. if [[ $i == 10 ]]; then
  43. echo "Timed out waiting for tendermint to start"
  44. exit 1
  45. fi
  46. done
  47. # wait for a new block
  48. h1=`curl -s $addr/status | jq .result.sync_info.latest_block_height`
  49. h2=$h1
  50. while [ "$h2" == "$h1" ]; do
  51. sleep 1
  52. h2=`curl -s $addr/status | jq .result.sync_info.latest_block_height`
  53. done
  54. kill_procs
  55. sleep 2
  56. echo "Passed Test: Persistence"