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.

54 lines
1.6 KiB

  1. # Tendermint P2P Tests
  2. These scripts facilitate setting up and testing a local testnet using docker containers.
  3. Setup your own local testnet as follows.
  4. For consistency, we assume all commands are run from the Tendermint repository root (ie. $GOPATH/src/github.com/tendermint/tendermint).
  5. First, build the docker image:
  6. ```
  7. docker build -t tendermint_tester -f ./test/docker/Dockerfile .
  8. ```
  9. Now create the docker network:
  10. ```
  11. docker network create --driver bridge --subnet 172.57.0.0/16 my_testnet
  12. ```
  13. This gives us a new network with IP addresses in the rage `172.57.0.0 - 172.57.255.255`.
  14. Peers on the network can have any IP address in this range.
  15. For our four node network, let's pick `172.57.0.101 - 172.57.0.104`.
  16. Since we use Tendermint's default listening port of 46656, our list of seed nodes will look like:
  17. ```
  18. 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656
  19. ```
  20. Now we can start up the peers. We already have config files setup in `test/p2p/data/`.
  21. Let's use a for-loop to start our peers:
  22. ```
  23. for i in $(seq 1 4); do
  24. docker run -d \
  25. --net=my_testnet\
  26. --ip="172.57.0.$((100 + $i))" \
  27. --name local_testnet_$i \
  28. --entrypoint tendermint \
  29. -e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$i/core \
  30. tendermint_tester node --seeds 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656 --proxy_app=dummy
  31. done
  32. ```
  33. If you now run `docker ps`, you'll see your containers!
  34. We can confirm they are making blocks by checking the `/status` message using `curl` and `jq` to pretty print the output json:
  35. ```
  36. curl 172.57.0.101:46657/status | jq .
  37. ```