|
| 1 | +# Test Data Generator |
| 2 | + |
| 3 | +Generates test data for ETH light client integration tests on NEAR. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +### Generate Sepolia Test Data |
| 8 | +```bash |
| 9 | +cd contracts/near/eth2-client/src/data/ |
| 10 | +uv run dump_sepolia_data.py |
| 11 | +``` |
| 12 | + |
| 13 | +### Dependencies |
| 14 | +Uses `uv` for fast dependency management: |
| 15 | +```bash |
| 16 | +# Install uv if needed |
| 17 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 18 | + |
| 19 | +# Dependencies auto-installed on first run with uv |
| 20 | +# Or manually: uv add requests web3 tqdm eth2spec |
| 21 | +``` |
| 22 | + |
| 23 | +### Environment Variables |
| 24 | +- `NETWORK`: Network name (default: `sepolia`) |
| 25 | +- `EXECUTION_RPC`: Ethereum RPC endpoint |
| 26 | +- `CONSENSUS_API`: Beacon chain API endpoint |
| 27 | +- `BLOCK_WINDOW`: Block window size (default: `50`) |
| 28 | +- `BATCH_SIZE`: RPC batch size (default: `50`) |
| 29 | + |
| 30 | +### Output Files |
| 31 | +- `{network}/execution_blocks_{start}_{end}.json`: Execution block headers |
| 32 | +- `{network}/light_client_update_period_{period}.json`: Light client updates |
| 33 | +- `{network}/beacon_header_{slot}.json`: Beacon block headers |
| 34 | + |
| 35 | +## Integration Tests |
| 36 | + |
| 37 | +The script generates data used by: |
| 38 | +- `get_sepolia_test_data()` in `tests/utils.rs` |
| 39 | +- Integration tests in `tests/integration_tests.rs` |
| 40 | + |
| 41 | +### Update Test Data |
| 42 | +1. Run the script to generate new data files |
| 43 | +2. Update hardcoded block numbers and periods in `tests/utils.rs:106-122` |
| 44 | +3. Run tests: `cargo test` |
| 45 | + |
| 46 | +### How It Works |
| 47 | +- Fetches 4 most recent light client update periods |
| 48 | +- Downloads corresponding execution blocks in 2 batches |
| 49 | +- Generates Merkle proofs for block hash verification |
| 50 | +- Creates normalized JSON files matching Rust struct format |
| 51 | + |
| 52 | +The test expects specific file patterns matching the periods and block ranges defined in `utils.rs`. |
0 commit comments