Skip to content

Commit 8b15066

Browse files
committed
test: add network integration test for ERC-6492 against mainnet RPC
Adds tests/chains/test_evm_integration.py with a single test that runs the real rejected Aleph message (f4daf9c0...fd0a8) end-to-end against a public Ethereum mainnet RPC, verifying the EIP-6492 contract-creation pattern actually works (not just against mocks). Uses a new 'network' pytest marker, excluded from the default run via addopts. Enable explicitly with: hatch run testing:test tests/chains/test_evm_integration.py -m network -v RPC URL is configurable via the ALEPH_TEST_ETH_RPC env var; defaults to ethereum-rpc.publicnode.com.
1 parent 479b105 commit 8b15066

2 files changed

Lines changed: 87 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,16 @@ keep_full_version = true
218218
[tool.pytest.ini_options]
219219
minversion = "6.0"
220220
pythonpath = [ "src" ]
221-
addopts = "-vv -m \"not ledger_hardware\""
221+
addopts = "-vv -m \"not ledger_hardware and not network\""
222222
filterwarnings = [
223223
"ignore:pkg_resources is deprecated as an API:UserWarning",
224224
]
225225
norecursedirs = [ "*.egg", "dist", "build", ".tox", ".venv", "*/site-packages/*", ".claude", ".worktrees" ]
226226
testpaths = [ "tests/unit" ]
227-
markers = { ledger_hardware = "marks tests as requiring ledger hardware" }
227+
markers = [
228+
"ledger_hardware: marks tests as requiring ledger hardware",
229+
"network: marks tests as requiring external network access (e.g. Ethereum mainnet RPC)",
230+
]
228231

229232
[tool.coverage.run]
230233
branch = true
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
Integration tests for EVMVerifier against a real Ethereum mainnet RPC.
3+
4+
These tests are marked `network` and excluded from the default pytest run.
5+
Enable them explicitly:
6+
7+
hatch run testing:test tests/chains/test_evm_integration.py -m network -v
8+
9+
Or override addopts:
10+
11+
hatch run testing:test tests/chains/test_evm_integration.py -m network -v \
12+
--override-ini="addopts="
13+
14+
Uses a public mainnet RPC by default. Override with ALEPH_TEST_ETH_RPC if you
15+
have your own node.
16+
"""
17+
18+
import os
19+
20+
import pytest
21+
22+
from aleph.chains.evm import EVMVerifier
23+
from aleph.schemas.pending_messages import BasePendingMessage, parse_message
24+
25+
ETH_MAINNET_RPC = os.environ.get(
26+
"ALEPH_TEST_ETH_RPC", "https://ethereum-rpc.publicnode.com"
27+
)
28+
29+
30+
# Real Aleph message signed by a Privy/Kernel counterfactual smart wallet.
31+
# Source: the production Aleph network, originally rejected before EIP-6492
32+
# support was added.
33+
# item_hash: f4daf9c0dadd7aa89c37e62e24f90a032183ba3b829b2bd2cf87568a940fd0a8
34+
REAL_ERC6492_MESSAGE = {
35+
"item_hash": "f4daf9c0dadd7aa89c37e62e24f90a032183ba3b829b2bd2cf87568a940fd0a8",
36+
"type": "POST",
37+
"chain": "ETH",
38+
"sender": "0xa9F3Cd4E416c6e911DB3DcB5CA6CD77e9F861635",
39+
"time": 1776949817.862,
40+
"item_type": "inline",
41+
"item_content": (
42+
'{"type":"ALEPH-SSH",'
43+
'"address":"0xa9F3Cd4E416c6e911DB3DcB5CA6CD77e9F861635",'
44+
'"content":{"key":"test1","label":"test1"},'
45+
'"time":1776949817.862}'
46+
),
47+
"channel": "ALEPH-CLOUDSOLUTIONS",
48+
"signature": "0x000000000000000000000000d703aae79538628d27099b8c4f621be4ccd142d50000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000001c4c5265d5d000000000000000000000000aac5d4240af87249b3f71bc8e4a2cae074a3e4190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000014fFFEfCDE25e1d00474530f1A7b90D02CEda94fD7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005601845ADb2C711129d4f3966735eD98a9F09fC4cE57ad3840a219707e52978ad891b851ac7302c95785dd6e233f010c205018312c7b1232d3eb5e60be5a12e41d3be3a9635660eea241fc2ef92cc461abf00d44b4831b000000000000000000006492649264926492649264926492649264926492649264926492649264926492", # noqa: E501
49+
}
50+
51+
52+
@pytest.fixture
53+
def real_erc6492_message() -> BasePendingMessage:
54+
return parse_message(REAL_ERC6492_MESSAGE)
55+
56+
57+
@pytest.mark.network
58+
@pytest.mark.asyncio
59+
async def test_erc6492_validation_against_mainnet(
60+
real_erc6492_message: BasePendingMessage,
61+
):
62+
"""End-to-end: real ERC-6492 sig + real mainnet RPC + EIP-6492 bytecode.
63+
64+
This test exercises the full happy path against a live Ethereum mainnet
65+
node:
66+
1. Detects the 0x6492…6492 magic suffix.
67+
2. Builds the ValidateSigOffchain deploy_data (bytecode + ABI-encoded args).
68+
3. eth_call with no `to` field → the bytecode runs as a constructor,
69+
deploys UniversalSigValidator inline, simulates the Kernel factory
70+
deployment, and calls isValidSignature.
71+
4. Asserts the returned byte is 0x01 (valid).
72+
73+
Verifies that the bogus-address bug is fixed and the EIP-6492
74+
contract-creation pattern works as specified.
75+
"""
76+
verifier = EVMVerifier(rpc_url=ETH_MAINNET_RPC)
77+
result = await verifier.verify_signature(real_erc6492_message)
78+
assert result is True, (
79+
"Expected the real ERC-6492 signature to validate against mainnet. "
80+
"If this fails, either the RPC is down or the bytecode asset drifted "
81+
"from the EIP-6492 reference implementation."
82+
)

0 commit comments

Comments
 (0)