Skip to content

Commit 1586de8

Browse files
committed
test: using live rpc endpoint
1 parent 27c22b7 commit 1586de8

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

backend/crates/bridge/src/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl RpcClientManager {
104104
///
105105
/// - **Attempt 0**: Immediate (no delay)
106106
/// - **Attempt 1**: After ~2s delay
107-
/// - **Attempt 2**: After ~3s delay
107+
/// - **Attempt 2**: After ~3s delay
108108
/// - **Attempt 3**: After ~5s delay
109109
/// - Total: ~10 seconds per operator
110110
///

backend/crates/bridge/src/withdrawal_indexer/task.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,65 @@ poll_interval_s = 0
304304
assert_eq!(state.last_scanned_block, 10);
305305
}
306306

307+
/// Smoke test against a live alpen-reth endpoint.
308+
///
309+
/// Run with:
310+
/// `ETH_RPC_URL=https://rpc.testnet.alpenlabs.io cargo test -p status-bridge \
311+
/// live_smoke -- --ignored --nocapture`
312+
///
313+
/// Verifies that the deployed event ABI still matches our pinned
314+
/// `alpen-reth-primitives` and that our decoder accepts every log returned
315+
/// by the precompile filter.
316+
#[tokio::test]
317+
#[ignore = "hits a live RPC; opt in with ETH_RPC_URL set + --ignored"]
318+
async fn live_smoke() {
319+
let url = match std::env::var("ETH_RPC_URL") {
320+
Ok(u) if !u.is_empty() => u,
321+
_ => {
322+
eprintln!("ETH_RPC_URL unset; skipping");
323+
return;
324+
}
325+
};
326+
let rpc = JsonRpcEthClient::new(&url).expect("build rpc client");
327+
328+
let head = rpc.block_number().await.expect("block_number");
329+
assert!(head > 0, "live chain head should be > 0");
330+
eprintln!("live head = {head}");
331+
332+
// Public testnet caps eth_getLogs at 100k blocks per request.
333+
let from = head.saturating_sub(100_000);
334+
let logs = rpc
335+
.get_logs(
336+
from,
337+
head,
338+
BRIDGEOUT_PRECOMPILE_ADDRESS,
339+
WithdrawalIntentEvent::SIGNATURE_HASH,
340+
)
341+
.await
342+
.expect("get_logs");
343+
eprintln!("found {} bridgeout logs in [{from}, {head}]", logs.len());
344+
345+
let mut total_sub_units = 0usize;
346+
for log in &logs {
347+
let rows = decoder::decode(log).unwrap_or_else(|e| {
348+
panic!(
349+
"decode failed for tx {:?} log_index {}: {e}",
350+
log.transaction_hash, log.log_index
351+
)
352+
});
353+
assert!(
354+
!rows.is_empty(),
355+
"every accepted log expands into ≥ 1 sub-unit"
356+
);
357+
total_sub_units += rows.len();
358+
}
359+
eprintln!(
360+
"decoded {} logs into {} sub-units total",
361+
logs.len(),
362+
total_sub_units
363+
);
364+
}
365+
307366
#[tokio::test]
308367
async fn restart_replay_is_idempotent() {
309368
let db = MockWithdrawalIndexerDb::default();

0 commit comments

Comments
 (0)