Skip to content

test(jsonrpc): add jsonrpc compatibility test #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 117 commits into from
Aug 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
f28c933
test(rpc-compat): add test simulator
cloudgray Aug 1, 2025
d2892a1
refactor(tests): jsonrpc test
cloudgray Aug 4, 2025
d389b8e
test(jsonprc): refactor test suite
cloudgray Aug 4, 2025
ea68a9d
test(jsonrpc): refactor test suite
cloudgray Aug 4, 2025
4a068bc
test(jsonrpc): refactor test suite
cloudgray Aug 4, 2025
46b4434
test(jsonrpc): add network start/stop scripts of evmd and geth
cloudgray Aug 5, 2025
39c6c10
test(jsonrpc): fix api counting in report
cloudgray Aug 5, 2025
8f32e50
test(jsonrpc): refactor result format
cloudgray Aug 6, 2025
92b26e9
test(jsonrpc): refactor
cloudgray Aug 6, 2025
e125461
test(jsonrpc): add state generator
cloudgray Aug 6, 2025
aa42107
test(jsonrpc): refactor simulator
cloudgray Aug 6, 2025
60185dd
test(jsonrpc): refactor
cloudgray Aug 6, 2025
44fdef2
test(jsonrpc): setup geth dev mode
cloudgray Aug 6, 2025
e154a07
test(jsonrpc): clean unused code
cloudgray Aug 6, 2025
540e38b
test(jsonrpc): setup initial state
cloudgray Aug 6, 2025
b2a5cfa
test(jsonrpc): add tx metadata for test
cloudgray Aug 6, 2025
9be672d
WIP: test(jsonrpc): fix some failing tests of eth_ apis
cloudgray Aug 7, 2025
d020b7f
test(jsonrpc): fix eth test
cloudgray Aug 7, 2025
89876e1
WIP: test(jsonrpc): fix debug api test cases
cloudgray Aug 7, 2025
58b814d
test(jsonrpc): set pruning config as nothing for testing
cloudgray Aug 7, 2025
f4bed6e
test(jsonrpc): enhance debug testing
cloudgray Aug 7, 2025
111e866
test(jsonrpc): fix net test case
cloudgray Aug 7, 2025
056bfa8
chore: update working history
cloudgray Aug 7, 2025
25081d5
test(jsonrpc): skip personal apis
cloudgray Aug 7, 2025
086f067
test(jsonrpc): add websocket api test
cloudgray Aug 7, 2025
7fdb7cb
jsonrpc(test): fix personal apis
cloudgray Aug 7, 2025
ef4d773
test(jsonrpc): add missing debug apis
cloudgray Aug 7, 2025
81dba15
test(jsonrpc): update working history
cloudgray Aug 7, 2025
d9df2e4
test(jsonrpc): fix eth_sign / eth_signTransaction test
cloudgray Aug 8, 2025
1ef72e2
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
905c6fd
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
5939c70
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
eb534d1
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
88344b5
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
1f27c38
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
f7eb447
test(jsonrpc): refactor simulator
cloudgray Aug 8, 2025
56f3861
test(jsonrpc): update working history
cloudgray Aug 8, 2025
ea9ae45
WIP: add type check between responses from evmd and geth
cloudgray Aug 11, 2025
66189f8
WIP: add type check between responses from evmd and geth
cloudgray Aug 11, 2025
fd38119
WIP: test(jsonrpc): add type check between responses from evmd and geth
cloudgray Aug 11, 2025
8847ef8
test(jsonrpc): modify test
cloudgray Aug 11, 2025
7a963bd
test(jsonrpc): add debug apis
cloudgray Aug 11, 2025
26f5cdc
test(jsonrpc): fix failing tests
cloudgray Aug 11, 2025
a04208f
test(jsonrpc): fix failing test
cloudgray Aug 11, 2025
194c199
test(jsonrpc): fix test
cloudgray Aug 11, 2025
9bc33e5
test(jsonrpc): fix test
cloudgray Aug 11, 2025
e8ab1e5
test(jsonrpc): remove unnecessary files
cloudgray Aug 12, 2025
cdc130b
chore: add compatibility test github ci job
cloudgray Aug 12, 2025
60feaf3
chore: update github-ci job
cloudgray Aug 12, 2025
2cc067f
chore: fix jsonrpc-compatibility test githib-ci job
cloudgray Aug 12, 2025
1ead1c1
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
ce77602
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
9c8bdf7
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
9a7fd2f
test(jsonrpc): refactor
cloudgray Aug 12, 2025
ae5fbec
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
c87857d
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
eefdf8a
test(jsonrpc): fix github-ci
cloudgray Aug 12, 2025
18924c9
test(jsonrpc): refactor test suite
cloudgray Aug 12, 2025
c91a9f2
fix github-ci
cloudgray Aug 12, 2025
3cc77b6
fix github-ci
cloudgray Aug 12, 2025
803750b
fix github-ci
cloudgray Aug 12, 2025
f5f8adf
fix: github-ci
cloudgray Aug 12, 2025
e250a8d
fix: github-ci
cloudgray Aug 12, 2025
3a649ec
test(jsonrpc): add eth tests
cloudgray Aug 12, 2025
9ca4476
WIP: chore: debugging github-ci failure
cloudgray Aug 12, 2025
f954f7c
fix: github-ci
cloudgray Aug 12, 2025
66065e5
test(jsonrpc): add missing debug tests
cloudgray Aug 12, 2025
b4957c9
fix github-ci
cloudgray Aug 12, 2025
a2e6a74
test(jsonrpc): add eth_pendingtransaction test
cloudgray Aug 13, 2025
b3a777a
fix: github-ci
cloudgray Aug 13, 2025
790cce7
test(jsonrpc): add missing debug tests
cloudgray Aug 13, 2025
97ba060
Revert "test(jsonrpc): add missing debug tests"
cloudgray Aug 13, 2025
628a4b0
Revert "fix: github-ci"
cloudgray Aug 13, 2025
61a0444
fix: github-ci
cloudgray Aug 13, 2025
053c6c8
fix: github-ci
cloudgray Aug 13, 2025
d434b9f
WIP: fix: github-ci
cloudgray Aug 13, 2025
ea91f92
WIP: fix github0-ci
cloudgray Aug 13, 2025
bac8b12
test(jsonrpc): refactor test suite
cloudgray Aug 13, 2025
97b7434
Merge branch 'main' into test/rpc-compat
cloudgray Aug 13, 2025
0e7129e
fix: github-ci
cloudgray Aug 13, 2025
05bd874
chore: add debug code for github-ci
cloudgray Aug 13, 2025
e7e24d2
chore: add debug code for github-ci
cloudgray Aug 13, 2025
b9dcc08
fix: github-ci
cloudgray Aug 13, 2025
51b8824
fix: github-ci
cloudgray Aug 13, 2025
481266d
test(jsonrpc): refactor test suite
cloudgray Aug 13, 2025
4cc82d1
test(jsonrpc): fix github-ci
cloudgray Aug 13, 2025
296e823
fix: github-ci
cloudgray Aug 13, 2025
c513802
fix: github-ci
cloudgray Aug 13, 2025
5fba53c
fix: github-ci
cloudgray Aug 13, 2025
4296543
fix: github-ci
cloudgray Aug 13, 2025
687f9c6
fix: github-ci
cloudgray Aug 13, 2025
a933c30
fix: github-ci
cloudgray Aug 13, 2025
fe462f5
fix github-ci
cloudgray Aug 13, 2025
b8252b4
test(jsonrpc): fix eth_getProof api
cloudgray Aug 13, 2025
e6f4e11
fix eth_getProof api
cloudgray Aug 13, 2025
bafdb48
fix: github-ci
cloudgray Aug 13, 2025
854c8d4
fix: github-ci
cloudgray Aug 13, 2025
c37c339
fix: github-ci
cloudgray Aug 13, 2025
c217ef3
test(jsonrpc): fix api test
cloudgray Aug 13, 2025
b5bebc5
fix: github-ci
cloudgray Aug 13, 2025
6780f24
fix: github-ci
cloudgray Aug 13, 2025
d1e7195
fix: github-ci
cloudgray Aug 13, 2025
63cc892
fix: github-ci
cloudgray Aug 13, 2025
ed7be1b
fix: github-ci
cloudgray Aug 13, 2025
f62ef68
fix: github-ci
cloudgray Aug 13, 2025
d2e7984
test(jsonrpc): modify test script
cloudgray Aug 13, 2025
01b397f
fix: github-ci
cloudgray Aug 13, 2025
32b1d3c
test(jsonrpc): refactor test suite
cloudgray Aug 13, 2025
efef814
test(jsonrpc): refactor test suite
cloudgray Aug 13, 2025
f474a53
test(jsonrpc): fix websocket api tests
cloudgray Aug 13, 2025
ec26ad7
chore: update README.md for jsonrpc test
cloudgray Aug 13, 2025
47da06d
Merge branch 'main' into test/rpc-compat
cloudgray Aug 13, 2025
0fa72b7
Merge branch 'main' into test/rpc-compat
aljo242 Aug 14, 2025
a32dfe6
chore: remove binary file
cloudgray Aug 18, 2025
310c720
Merge branch 'main' into test/rpc-compat
cloudgray Aug 18, 2025
416d264
Merge branch 'main' into test/rpc-compat
aljo242 Aug 18, 2025
b76f2f6
Merge branch 'main' into test/rpc-compat
aljo242 Aug 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/jsonrpc-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: JSON-RPC Compatibility Test
on:
pull_request:
paths:
- '.github/workflows/jsonrpc-compatibility.yml'
- 'tests/jsonrpc/**'
- 'rpc/**'
- 'evmd/**'
- '**/**.go'
- 'go.mod'
- 'go.sum'
- 'evmd/go.mod'
- 'evmd/go.sum'
merge_group:
push:
branches:
- main
- release/**
permissions: read-all

jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main' }}

jsonrpc-compatibility-test:
runs-on: depot-ubuntu-22.04-8
timeout-minutes: 45
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true

- uses: actions/checkout@v4

- uses: technote-space/[email protected]
with:
PATTERNS: |
.github/workflows/jsonrpc-compatibility.yml
tests/jsonrpc/**
rpc/**
evmd/**
**/**.go
go.mod
go.sum
evmd/go.mod
evmd/go.sum

- name: Set up Docker
uses: docker/setup-buildx-action@v3
if: ${{ env.GIT_DIFF }}

- name: Run JSON-RPC compatibility tests
run: |
echo "🧪 Running JSON-RPC compatibility tests using containerized environment..."

# Run the containerized test suite
make test-rpc-compat > test_output.log 2>&1 || {
echo "⚠️ Test exited with non-zero code, checking results..."
}

# Display the test output
cat test_output.log

# Check for failure criterion: count of "Failed" tests > 0
failed_count=$(grep -o "Failed:.*[0-9]" test_output.log | grep -o "[0-9]\+" | head -1 || echo "0")

echo "📊 Test Results Summary:"
echo " Failed tests: $failed_count"

if [ "$failed_count" -gt 0 ]; then
echo "❌ CI FAILURE: Found $failed_count failed tests"
echo " Criterion: CI fails when any test has status 'Failed' (not 'Not Implemented', 'Legacy', or 'Skipped')"
exit 1
else
echo "✅ CI PASS: No failed tests found"
echo " Note: 'Not Implemented', 'Legacy', and 'Skipped' tests are acceptable and don't cause CI failure"
fi
if: ${{ env.GIT_DIFF }}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ localnet-stop:
localnet-start: localnet-stop localnet-build-env localnet-build-nodes


.PHONY: localnet-start localnet-stop localnet-build-env localnet-build-nodes
test-rpc-compat:
@./tests/jsonrpc/scripts/run-compat-test.sh

test-rpc-compat-stop:
cd tests/jsonrpc && docker compose down

.PHONY: localnet-start localnet-stop localnet-build-env localnet-build-nodes test-rpc-compat test-rpc-compat-stop

test-system: build
ulimit -n 1300
Expand Down
2 changes: 1 addition & 1 deletion contrib/images/evmd-env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ RUN chown -R nonroot:nonroot /evmd
USER nonroot

ENTRYPOINT ["/usr/bin/wrapper.sh"]
CMD ["start", "--log_format", "plain", "--minimum-gas-prices", "0.0001atest", "--json-rpc.api", "eth,txpool,personal,net,debug,web3", "--chain-id", "local-4221"]
CMD ["start", "--log_format", "plain", "--minimum-gas-prices", "0.0001atest", "--json-rpc.enable", "true", "--json-rpc.api", "eth,txpool,personal,net,debug,web3", "--chain-id", "local-4221"]
2 changes: 2 additions & 0 deletions tests/jsonrpc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.evmd/
.geth-data/
40 changes: 40 additions & 0 deletions tests/jsonrpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dockerfile for JSON-RPC Compatibility Test Simulator
FROM golang:1.24-alpine AS builder

# Install dependencies
RUN apk add --no-cache git

# Set working directory
WORKDIR /workspace

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy the entire source code
COPY . .

# Build the simulator
WORKDIR /workspace/tests/jsonrpc/simulator
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o simulator .

# Final stage
FROM alpine:latest

# Install ca-certificates and curl for debugging
RUN apk --no-cache add ca-certificates curl

# Set working directory
WORKDIR /app

# Copy the binary
COPY --from=builder /workspace/tests/jsonrpc/simulator/simulator .

# Copy contract files needed at runtime
COPY --from=builder /workspace/tests/jsonrpc/simulator/contracts ./contracts

# Make it executable
RUN chmod +x simulator

# Default command
CMD ["./simulator"]
126 changes: 126 additions & 0 deletions tests/jsonrpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# JSON-RPC Compatibility Testing

This directory contains tools and scripts for testing JSON-RPC API compatibility between Cosmos EVM and Ethereum clients.

## Quick Start

```bash
# From project root
make test-rpc-compat
```

## Test Guide

### 1. Build EVMD Docker Image

```bash
# From project root
make localnet-build-env
```

### 2. Start Nodes

```bash
# Start evmd with JSON-RPC enabled
./tests/jsonrpc/scripts/evmd/start-evmd.sh

# Start geth for comparison
./tests/jsonrpc/scripts/geth/start-geth.sh

# Or start both at once
./tests/jsonrpc/scripts/start-networks.sh
```

### 3. Run Compatibility Tests

```bash
# Use the simulator for comprehensive testing
cd tests/jsonrpc/simulator
go build .
./simulator
```

### 4. Stop Nodes

```bash
# Stop evmd
./tests/jsonrpc/scripts/evmd/stop-evmd.sh

# Stop geth
./tests/jsonrpc/scripts/geth/stop-geth.sh

# Or stop both at once
./tests/jsonrpc/scripts/stop-networks.sh
```

## Available Endpoints

### evmd Endpoints

- **JSON-RPC**: http://localhost:8545
- **WebSocket**: ws://localhost:8546
- **Cosmos REST**: http://localhost:1317
- **Tendermint RPC**: http://localhost:26657
- **gRPC**: localhost:9090

### geth Endpoints

- **JSON-RPC**: http://localhost:8547
- **WebSocket**: ws://localhost:8548

## Scripts Structure

### `scripts/evmd/`

- `start-evmd.sh` - Initialize and start single-node evmd for testing
- `stop-evmd.sh` - Stop the evmd testing node

### `scripts/geth/`

- `start-geth.sh` - Start geth node using ethereum/client-go:v1.15.10
- `stop-geth.sh` - Stop the geth testing node

### `scripts/`

- `start-both.sh` - Start both evmd and geth nodes
- `stop-both.sh` - Stop both nodes

## Testing with Simulator

The simulator in `./simulator/` is the primary tool for comprehensive compatibility testing:

```bash
cd tests/jsonrpc/simulator
go build .
./simulator
```

## Configuration

The scripts use the following defaults:

### evmd Configuration

- Container name: `evmd-jsonrpc-test`
- Chain ID: `local-4221`
- Validator count: 1
- Data directory: `tests/jsonrpc/.evmd`

### geth Configuration

- Container name: `geth-jsonrpc-test`
- Chain ID: 1337 (dev mode)
- Data directory: `tests/jsonrpc/.geth-data`

## Troubleshooting

### Container fails to start

- Check if the Docker image was built: `docker images | grep cosmos/evmd`
- Check container logs: `docker logs evmd-jsonrpc-test`

### JSON-RPC not responding

- Verify the container is running: `docker ps | grep evmd-jsonrpc-test`
- Check if ports are bound: `docker port evmd-jsonrpc-test`
- Test with curl: `curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' http://localhost:8545`
93 changes: 93 additions & 0 deletions tests/jsonrpc/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
version: "3"

services:
evmd:
container_name: evmd-compat-test
image: "cosmos/evmd"
privileged: true
user: root
environment:
- DEBUG=0
- ID=0
- LOG=${LOG:-evmd.log}
- EVMDHOME=/data/node0/evmd
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
ports:
- "8545:8545"
- "8546:8546"
volumes:
- ./.evmd:/data:Z
- ./scripts/evmd/container-start-evmd.sh:/container-start-evmd.sh:ro
networks:
- jsonrpc-test
entrypoint: ["/bin/sh", "-c"]
command: ["/container-start-evmd.sh"]
healthcheck:
test: ["CMD", "sh", "-c", "wget --no-verbose --tries=1 --timeout=5 --post-data='{\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"params\":[],\"id\":1}' --header='Content-Type: application/json' -O- http://localhost:8545 | grep -q result || exit 1"]
interval: 10s
timeout: 10s
retries: 8
start_period: 45s

geth:
container_name: geth-compat-test
image: "ethereum/client-go:latest"
privileged: true
ports:
- "8547:8545"
- "8548:8546"
networks:
- jsonrpc-test
command: >
--dev
--dev.period 1
--http
--http.addr 0.0.0.0
--http.port 8545
--http.api eth,net,web3,personal,admin,debug,miner,txpool
--http.corsdomain "*"
--http.vhosts "*"
--ws
--ws.addr 0.0.0.0
--ws.port 8546
--ws.api eth,net,web3,personal,admin,debug,miner,txpool
--ws.origins "*"
--allow-insecure-unlock
--rpc.allow-unprotected-txs
--nodiscover
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8545"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s

simulator:
container_name: simulator-compat-test
privileged: true
build:
context: ../../
dockerfile: tests/jsonrpc/Dockerfile
depends_on:
evmd:
condition: service_healthy
geth:
condition: service_healthy
restart: on-failure
networks:
- jsonrpc-test
environment:
- EVMD_URL=http://evmd:8545
- EVMD_WS_URL=ws://evmd:8546
- GETH_URL=http://geth:8545
- GETH_WS_URL=ws://geth:8546
volumes:
- ./simulator:/app/results:Z
command: ["sh", "-c", "sleep 5 && ./simulator"]

networks:
jsonrpc-test:
driver: bridge
Loading
Loading