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.

69 lines
1.6 KiB

8 years ago
  1. #! /bin/bash
  2. cd $GOPATH/src/github.com/tendermint/go-rpc
  3. # get deps
  4. go get -u -t ./...
  5. # go tests
  6. go test --race github.com/tendermint/go-rpc/...
  7. # integration tests
  8. cd test
  9. set -e
  10. go build -o server main.go
  11. ./server > /dev/null &
  12. PID=$!
  13. sleep 2
  14. # simple request
  15. R1=`curl -s 'http://localhost:8008/hello_world?name="my_world"&num=5'`
  16. R2=`curl -s --data @data.json http://localhost:8008`
  17. if [[ "$R1" != "$R2" ]]; then
  18. echo "responses are not identical:"
  19. echo "R1: $R1"
  20. echo "R2: $R2"
  21. exit 1
  22. else
  23. echo "Success"
  24. fi
  25. # request with 0x-prefixed hex string arg
  26. R1=`curl -s 'http://localhost:8008/hello_world?name=0x41424344&num=123'`
  27. R2='{"jsonrpc":"2.0","id":"","result":{"Result":"hi ABCD 123"},"error":""}'
  28. if [[ "$R1" != "$R2" ]]; then
  29. echo "responses are not identical:"
  30. echo "R1: $R1"
  31. echo "R2: $R2"
  32. exit 1
  33. else
  34. echo "Success"
  35. fi
  36. # request with unquoted string arg
  37. R1=`curl -s 'http://localhost:8008/hello_world?name=abcd&num=123'`
  38. R2="{\"jsonrpc\":\"2.0\",\"id\":\"\",\"result\":null,\"error\":\"Error converting http params to args: invalid character 'a' looking for beginning of value\"}"
  39. if [[ "$R1" != "$R2" ]]; then
  40. echo "responses are not identical:"
  41. echo "R1: $R1"
  42. echo "R2: $R2"
  43. exit 1
  44. else
  45. echo "Success"
  46. fi
  47. # request with string type when expecting number arg
  48. R1=`curl -s 'http://localhost:8008/hello_world?name="abcd"&num=0xabcd'`
  49. R2="{\"jsonrpc\":\"2.0\",\"id\":\"\",\"result\":null,\"error\":\"Error converting http params to args: Got a hex string arg, but expected 'int'\"}"
  50. if [[ "$R1" != "$R2" ]]; then
  51. echo "responses are not identical:"
  52. echo "R1: $R1"
  53. echo "R2: $R2"
  54. exit 1
  55. else
  56. echo "Success"
  57. fi
  58. kill -9 $PID || exit 0