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.

57 lines
1.1 KiB

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