|
| 1 | +# JSON-RPC Compatibility Testing |
| 2 | + |
| 3 | +This directory contains tools and scripts for testing JSON-RPC API compatibility between Cosmos EVM and Ethereum clients. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# From project root |
| 9 | +make test-rpc-compat |
| 10 | +``` |
| 11 | + |
| 12 | +## Test Guide |
| 13 | + |
| 14 | +### 1. Build EVMD Docker Image |
| 15 | + |
| 16 | +```bash |
| 17 | +# From project root |
| 18 | +make localnet-build-env |
| 19 | +``` |
| 20 | + |
| 21 | +### 2. Start Nodes |
| 22 | + |
| 23 | +```bash |
| 24 | +# Start evmd with JSON-RPC enabled |
| 25 | +./tests/jsonrpc/scripts/evmd/start-evmd.sh |
| 26 | + |
| 27 | +# Start geth for comparison |
| 28 | +./tests/jsonrpc/scripts/geth/start-geth.sh |
| 29 | + |
| 30 | +# Or start both at once |
| 31 | +./tests/jsonrpc/scripts/start-networks.sh |
| 32 | +``` |
| 33 | + |
| 34 | +### 3. Run Compatibility Tests |
| 35 | + |
| 36 | +```bash |
| 37 | +# Use the simulator for comprehensive testing |
| 38 | +cd tests/jsonrpc/simulator |
| 39 | +go build . |
| 40 | +./simulator |
| 41 | +``` |
| 42 | + |
| 43 | +### 4. Stop Nodes |
| 44 | + |
| 45 | +```bash |
| 46 | +# Stop evmd |
| 47 | +./tests/jsonrpc/scripts/evmd/stop-evmd.sh |
| 48 | + |
| 49 | +# Stop geth |
| 50 | +./tests/jsonrpc/scripts/geth/stop-geth.sh |
| 51 | + |
| 52 | +# Or stop both at once |
| 53 | +./tests/jsonrpc/scripts/stop-networks.sh |
| 54 | +``` |
| 55 | + |
| 56 | +## Available Endpoints |
| 57 | + |
| 58 | +### evmd Endpoints |
| 59 | + |
| 60 | +- **JSON-RPC**: http://localhost:8545 |
| 61 | +- **WebSocket**: ws://localhost:8546 |
| 62 | +- **Cosmos REST**: http://localhost:1317 |
| 63 | +- **Tendermint RPC**: http://localhost:26657 |
| 64 | +- **gRPC**: localhost:9090 |
| 65 | + |
| 66 | +### geth Endpoints |
| 67 | + |
| 68 | +- **JSON-RPC**: http://localhost:8547 |
| 69 | +- **WebSocket**: ws://localhost:8548 |
| 70 | + |
| 71 | +## Scripts Structure |
| 72 | + |
| 73 | +### `scripts/evmd/` |
| 74 | + |
| 75 | +- `start-evmd.sh` - Initialize and start single-node evmd for testing |
| 76 | +- `stop-evmd.sh` - Stop the evmd testing node |
| 77 | + |
| 78 | +### `scripts/geth/` |
| 79 | + |
| 80 | +- `start-geth.sh` - Start geth node using ethereum/client-go:v1.15.10 |
| 81 | +- `stop-geth.sh` - Stop the geth testing node |
| 82 | + |
| 83 | +### `scripts/` |
| 84 | + |
| 85 | +- `start-both.sh` - Start both evmd and geth nodes |
| 86 | +- `stop-both.sh` - Stop both nodes |
| 87 | + |
| 88 | +## Testing with Simulator |
| 89 | + |
| 90 | +The simulator in `./simulator/` is the primary tool for comprehensive compatibility testing: |
| 91 | + |
| 92 | +```bash |
| 93 | +cd tests/jsonrpc/simulator |
| 94 | +go build . |
| 95 | +./simulator |
| 96 | +``` |
| 97 | + |
| 98 | +## Configuration |
| 99 | + |
| 100 | +The scripts use the following defaults: |
| 101 | + |
| 102 | +### evmd Configuration |
| 103 | + |
| 104 | +- Container name: `evmd-jsonrpc-test` |
| 105 | +- Chain ID: `local-4221` |
| 106 | +- Validator count: 1 |
| 107 | +- Data directory: `tests/jsonrpc/.evmd` |
| 108 | + |
| 109 | +### geth Configuration |
| 110 | + |
| 111 | +- Container name: `geth-jsonrpc-test` |
| 112 | +- Chain ID: 1337 (dev mode) |
| 113 | +- Data directory: `tests/jsonrpc/.geth-data` |
| 114 | + |
| 115 | +## Troubleshooting |
| 116 | + |
| 117 | +### Container fails to start |
| 118 | + |
| 119 | +- Check if the Docker image was built: `docker images | grep cosmos/evmd` |
| 120 | +- Check container logs: `docker logs evmd-jsonrpc-test` |
| 121 | + |
| 122 | +### JSON-RPC not responding |
| 123 | + |
| 124 | +- Verify the container is running: `docker ps | grep evmd-jsonrpc-test` |
| 125 | +- Check if ports are bound: `docker port evmd-jsonrpc-test` |
| 126 | +- Test with curl: `curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' http://localhost:8545` |
0 commit comments