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

  1. #! /bin/bash
  2. #####################
  3. # counter over socket
  4. #####################
  5. TESTNAME=$1
  6. # Send some txs
  7. function sendTx() {
  8. TX=$1
  9. RESPONSE=`curl -s localhost:46657/broadcast_tx_commit?tx=\"$TX\"`
  10. CODE=`echo $RESPONSE | jq .result[1].code`
  11. ERROR=`echo $RESPONSE | jq .error`
  12. ERROR=$(echo "$ERROR" | tr -d '"') # remove surrounding quotes
  13. }
  14. # 0 should pass once and get in block, with no error
  15. TX=00
  16. sendTx $TX
  17. if [[ $CODE != 0 ]]; then
  18. echo "Got non-zero exit code for $TX. $RESPONSE"
  19. exit 1
  20. fi
  21. if [[ "$ERROR" != "" ]]; then
  22. echo "Unexpected error. Tx $TX should have been included in a block. $ERROR"
  23. exit 1
  24. fi
  25. # second time should get rejected by the mempool (return error and non-zero code)
  26. sendTx $TX
  27. if [[ $CODE == 0 ]]; then
  28. echo "Got zero exit code for $TX. Expected tx to be rejected by mempool. $RESPONSE"
  29. exit 1
  30. fi
  31. if [[ "$ERROR" == "" ]]; then
  32. echo "Expected to get an error - tx $TX should have been rejected from mempool"
  33. echo "$RESPONSE"
  34. exit 1
  35. fi
  36. # now, TX=01 should pass, with no error
  37. TX=01
  38. sendTx $TX
  39. if [[ $CODE != 0 ]]; then
  40. echo "Got non-zero exit code for $TX. $RESPONSE"
  41. exit 1
  42. fi
  43. if [[ "$ERROR" != "" ]]; then
  44. echo "Unexpected error. Tx $TX should have been accepted in block. $ERROR"
  45. exit 1
  46. fi
  47. # now, TX=03 should get in a block (passes CheckTx, no error), but is invalid
  48. TX=03
  49. sendTx $TX
  50. if [[ $CODE == 0 ]]; then
  51. echo "Got zero exit code for $TX. Should have been bad nonce. $RESPONSE"
  52. exit 1
  53. fi
  54. if [[ "$ERROR" != "" ]]; then
  55. echo "Unexpected error. Tx $TX should have been included in a block. $ERROR"
  56. exit 1
  57. fi
  58. echo "Passed Test: $TESTNAME"