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.

42 lines
1.0 KiB

  1. #! /bin/bash
  2. set -e
  3. go build -o server main.go
  4. ./server > /dev/null &
  5. PID=$!
  6. sleep 2
  7. # simple JSONRPC request
  8. R1=`curl -s 'http://localhost:8008/hello_world?name="my_world"&num=5'`
  9. R2=`curl -s --data @data.json http://localhost:8008`
  10. if [[ "$R1" != "$R2" ]]; then
  11. echo "responses are not identical:"
  12. echo "R1: $R1"
  13. echo "R2: $R2"
  14. else
  15. echo "Success"
  16. fi
  17. # request with 0x-prefixed hex string arg
  18. R1=`curl -s 'http://localhost:8008/hello_world?name=0x41424344&num=123'`
  19. R2='{"jsonrpc":"2.0","id":"","result":{"Result":"hi ABCD 123"},"error":""}'
  20. if [[ "$R1" != "$R2" ]]; then
  21. echo "responses are not identical:"
  22. echo "R1: $R1"
  23. echo "R2: $R2"
  24. else
  25. echo "Success"
  26. fi
  27. # request with unquoted string arg
  28. R1=`curl -s 'http://localhost:8008/hello_world?name=abcd&num=123'`
  29. R2="{\"jsonrpc\":\"2.0\",\"id\":\"\",\"result\":null,\"error\":\"Error converting http params to args: invalid character 'a' looking for beginning of value\"}"
  30. if [[ "$R1" != "$R2" ]]; then
  31. echo "responses are not identical:"
  32. echo "R1: $R1"
  33. echo "R2: $R2"
  34. else
  35. echo "Success"
  36. fi
  37. kill -9 $PID