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.

78 lines
1.6 KiB

  1. #! /bin/bash
  2. set -e
  3. function toHex() {
  4. echo -n $1 | hexdump -ve '1/1 "%.2X"'
  5. }
  6. #####################
  7. # dummy with curl
  8. #####################
  9. TESTNAME=$1
  10. # store key value pair
  11. KEY="abcd"
  12. VALUE="dcba"
  13. curl -s 127.0.0.1:46657/broadcast_tx_commit?tx=\"$(toHex $KEY=$VALUE)\"
  14. echo $?
  15. echo ""
  16. ###########################
  17. # test using the tmsp-cli
  18. ###########################
  19. # we should be able to look up the key
  20. RESPONSE=`tmsp-cli query $KEY`
  21. set +e
  22. A=`echo $RESPONSE | grep exists=true`
  23. if [[ $? != 0 ]]; then
  24. echo "Failed to find 'exists=true' for $KEY. Response:"
  25. echo "$RESPONSE"
  26. exit 1
  27. fi
  28. set -e
  29. # we should not be able to look up the value
  30. RESPONSE=`tmsp-cli query $VALUE`
  31. set +e
  32. A=`echo $RESPONSE | grep exists=true`
  33. if [[ $? == 0 ]]; then
  34. echo "Found 'exists=true' for $VALUE when we should not have. Response:"
  35. echo "$RESPONSE"
  36. exit 1
  37. fi
  38. set -e
  39. #############################
  40. # test using the /tmsp_query
  41. #############################
  42. # we should be able to look up the key
  43. RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=\"$(toHex $KEY)\"`
  44. RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
  45. set +e
  46. A=`echo $RESPONSE | grep exists=true`
  47. if [[ $? != 0 ]]; then
  48. echo "Failed to find 'exists=true' for $KEY. Response:"
  49. echo "$RESPONSE"
  50. exit 1
  51. fi
  52. set -e
  53. # we should not be able to look up the value
  54. RESPONSE=`curl -s 127.0.0.1:46657/tmsp_query?query=\"$(toHex $VALUE)\"`
  55. RESPONSE=`echo $RESPONSE | jq .result[1].result.Data | xxd -r -p`
  56. set +e
  57. A=`echo $RESPONSE | grep exists=true`
  58. if [[ $? == 0 ]]; then
  59. echo "Found 'exists=true' for $VALUE when we should not have. Response:"
  60. echo "$RESPONSE"
  61. exit 1
  62. fi
  63. set -e
  64. echo "Passed Test: $TESTNAME"