Table of Contents
- How to install and start a testnet?
This manual describes how you can configure a testnet.
Here are some terms to start with:
- Testnet,
- Test chain.
These terms mean the same, except that you can form your testnet out of more than one chain.
Attention
This testnet uses preinstalled private keys for nodes. These keys are open and used for testing purposes only. Therefore, the testnet will be compromised when using it in a real-world system.
To start the testnet, ensure you have the following software installed on your machine:
- git,
- docker-compose.
Note
If you use Unix, you must be included into the user group
docker
to usedocker-compose
.To check the groups, you are included into, run:
user@root:~$ groups
To include your account into the group
docker
, run:usermod + dockerThis group is available only after you have installed Docker. If you haven't installed it yet, here is a How-To. Go to the link and choose your OS.
To install the testnet:
-
Clone the
test_chain
repository into your working directory using the following command:git clone https://github.com/thepower/test_chain.git
-
Go to
test_chain
directory:cd test_chain
To start a testnet, run:
docker-compose up -d
After starting the testnet, node API is available under the following addresses:
http://localhost:44001/api/status
http://localhost:44002/api/status
http://localhost:44003/api/status
To test your chain, run the following sequence of commands:
curl http://localhost:44001/api/node/status | jq
curl http://localhost:44001/api/block/last | jq
Please, stop your local testnet after completing all necessary testing or development. To stop the testnet, run:
docker-compose down
As an option, you can use Vagrant to setup development environment.
Here is an example of setting up the development environment for MacOS.
To set up Vagrant, follow the steps below:
-
Install vagrant:
brew install caskroom/cask/vagrant
-
If you use a VM:
-
For Parallels, add Parallels support to Vagrant:
vagrant plugin install vagrant-parallels
-
For VirtualBox (default option), modify the
PATH
variable to add the VirtualBox binary to Vagrant:export PATH=/Applications/VirtualBox.app/Contents/MacOS:$PATH
-
-
Install the hostmanager plugin to manage the
/etc/hosts
file:vagrant plugin install vagrant-hostmanager
To set up the environment, follow the steps below:
-
Clone the
tpnode
repository from Github and go totpnode
directory. -
Start the virtual machine using Vagrant:
vagrant up
Attention
When running the Vagrant command, provisioning will be started. During the provisioning, Vagrant downloads all the necessary libraries and compiles the proper versions of Erlang and other environment components.Reboot the virtual machine after successful provisioning using the following commands:
vagrant halt
vagrant up
-
Connect to virtual environment by running:
vagrant ssh -- -A
where:
-A
— key to ssh agent forwarding. You will be able to use ssh key from host machine to perform operations inside the virtual machine.
-
Go to the project directory:
cd /vagrant
-
Compile the testnet by running the following command:
make buildtest
-
Start the testnet by running the script:
./bin/testnet.sh
To stop the testnet, run:
./bin/testnet.sh stop
You can also use the Makefile targets as a reference on how to perform other tasks.
You can see the API ports by running:
netstat -an |grep 498
Note
After you've started testnet you should see 9 different ports. You can use these ports for The Power nodes API calls.
API call sample:
curl http://pwr.local:49841/api/node/status | jq .Note: the domain
pwr.local
in URL is used to reference the node from virtual or host machine.