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.

53 lines
1.0 KiB

  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 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, commit, get hash
  15. # hashes should be non-empty and identical
  16. echo "Dummy batch test ..."
  17. OUTPUT=`(tmsp batch) <<STDIN
  18. append_tx abc
  19. get_hash
  20. commit
  21. get_hash
  22. STDIN`
  23. HASH1=`echo "$OUTPUT" | tail -n 3 | head -n 1`
  24. HASH2=`echo "$OUTPUT" | tail -n 1`
  25. if [[ "$HASH1" == "" ]]; then
  26. echo "Expected non empty hash!"
  27. exit 1
  28. fi
  29. if [[ "$HASH1" != "$HASH2" ]]; then
  30. echo "Expected hashes before and after commit to match: $HASH1, $HASH2"
  31. exit 1
  32. fi
  33. echo "... Pass!"
  34. echo ""
  35. # Start a new connection and ensure the hash is the same
  36. echo "New connection test ..."
  37. RESULT_HASH=`tmsp get_hash`
  38. if [[ "$HASH1" != "$RESULT_HASH" ]]; then
  39. echo "Expected hash to persist as $HASH1 for new connection. Got $RESULT_HASH"
  40. exit 1
  41. fi
  42. echo "... Pass!"
  43. echo ""
  44. kill $PID
  45. sleep 1