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.

66 lines
2.2 KiB

  1. #! /bin/bash
  2. set -eu
  3. DOCKER_IMAGE=$1
  4. NETWORK_NAME=$2
  5. N=$3
  6. PROXY_APP=$4
  7. ID=1
  8. echo "----------------------------------------------------------------------"
  9. echo "Testing pex creates the addrbook and uses it if persistent_peers are not provided"
  10. echo "(assuming peers are started with pex enabled)"
  11. CLIENT_NAME="pex_addrbook_$ID"
  12. echo "1. restart peer $ID"
  13. docker stop "local_testnet_$ID"
  14. echo "stopped local_testnet_$ID"
  15. # preserve addrbook.json
  16. docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json" "/tmp/addrbook.json"
  17. set +e #CIRCLE
  18. docker rm -vf "local_testnet_$ID"
  19. set -e
  20. # NOTE that we do not provide persistent_peers
  21. bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
  22. echo "started local_testnet_$ID"
  23. # if the client runs forever, it means addrbook wasn't saved or was empty
  24. bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N"
  25. # Now we know that the node is up.
  26. docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json"
  27. echo "with the following addrbook:"
  28. cat /tmp/addrbook.json
  29. # exec doesn't work on circle
  30. # docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json"
  31. echo ""
  32. echo "----------------------------------------------------------------------"
  33. echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook"
  34. echo "(assuming peers are started with pex enabled)"
  35. CLIENT_NAME="pex_no_addrbook_$ID"
  36. echo "1. restart peer $ID"
  37. docker stop "local_testnet_$ID"
  38. echo "stopped local_testnet_$ID"
  39. set +e #CIRCLE
  40. docker rm -vf "local_testnet_$ID"
  41. set -e
  42. # NOTE that we do not provide persistent_peers
  43. bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe"
  44. echo "started local_testnet_$ID"
  45. # if the client runs forever, it means other peers have removed us from their books (which should not happen)
  46. bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N"
  47. # Now we know that the node is up.
  48. echo ""
  49. echo "PASS"
  50. echo ""