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.

61 lines
1.2 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  1. #! /bin/bash
  2. function finish {
  3. echo "Cleaning up..."
  4. ps -p $PID > /dev/null
  5. if [[ "$?" == "0" ]]; then
  6. kill -9 $PID
  7. fi
  8. }
  9. trap finish EXIT
  10. # Make sure the tmsp cli can connect to the dummy
  11. echo "Dummy test ..."
  12. dummy &> /dev/null &
  13. PID=`echo $!`
  14. sleep 1
  15. RESULT_HASH=`tmsp-cli get_hash`
  16. if [[ "$RESULT_HASH" != "" ]]; then
  17. echo "Expected nothing but got: $RESULT_HASH"
  18. exit 1
  19. fi
  20. echo "... Pass!"
  21. echo ""
  22. # Add a tx, get hash, get hash
  23. # hashes should be non-empty and identical
  24. echo "Dummy batch test ..."
  25. OUTPUT=`(tmsp-cli batch) <<STDIN
  26. append_tx abc
  27. get_hash
  28. get_hash
  29. STDIN`
  30. HASH1=`echo "$OUTPUT" | tail -n 2 | head -n 1`
  31. HASH2=`echo "$OUTPUT" | tail -n 1`
  32. if [[ "$HASH1" == "" ]]; then
  33. echo "Expected non empty hash!"
  34. exit 1
  35. fi
  36. if [[ "$HASH1" == "EOF" ]]; then
  37. echo "Expected hash not broken connection!"
  38. exit 1
  39. fi
  40. if [[ "$HASH1" != "$HASH2" ]]; then
  41. echo "Expected first and second hashes to match: $HASH1, $HASH2"
  42. exit 1
  43. fi
  44. echo "... Pass!"
  45. echo ""
  46. # Start a new connection and ensure the hash is the same
  47. echo "New connection test ..."
  48. RESULT_HASH=`tmsp-cli get_hash`
  49. if [[ "$HASH1" != "$RESULT_HASH" ]]; then
  50. echo "Expected hash to persist as $HASH1 for new connection. Got $RESULT_HASH"
  51. exit 1
  52. fi
  53. echo "... Pass!"
  54. echo ""