This directory contains a script to easily spin up a local testnet for ChatChain with 4 nodes and a client.
- Rust and Cargo installed
curlandlsofcommands available in your terminal- Ports 8080-8084 available on your machine
To start the testnet with 4 nodes and a client, simply run:
./start_testnet.shThis will:
- Create a
dbdirectory if it doesn't exist - Kill any existing node or client processes
- Clean up any existing database files
- Generate a
config.tomlfile for the testnet configuration - Start 4 nodes (on ports 8081-8084)
- Start the client (on port 8080)
- Wait for all nodes to be ready
The testnet is configured with:
- 4 nodes, each with its own database file (
node_0.redb,node_1.redb, etc.) - Each node connects to all other nodes in the network
- The client connects to all nodes for redundancy
- Nodes listen on ports 8081, 8082, 8083, and 8084
- The client listens on port 8080
Once the testnet is running, you can interact with it via the client API:
- Send a message:
curl -X POST http://localhost:8080/messages -H "Content-Type: application/json" -d '{"sender":"alice", "recipient":"bob", "text":"Hello!", "timestamp":1234567890}' - Get all messages:
curl http://localhost:8080/messages - Get network status:
curl http://localhost:8080/network
You can also interact directly with individual nodes using similar endpoints.
To stop the testnet, press Ctrl+C in the terminal where it's running. The script will handle proper shutdown of all processes.