Skip to content
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

feat(rpc-testing-utils) : enhanced tansaction replay #5275

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Changes from 1 commit
Commits
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
30 changes: 28 additions & 2 deletions crates/rpc/rpc-testing-util/tests/it/trace.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use futures::StreamExt;
use jsonrpsee::http_client::HttpClientBuilder;
use reth_rpc_api_testing_util::{trace::TraceApiExt, utils::parse_env_url};
use std::time::Instant;

use reth_rpc_types::trace::parity::TraceType;
use std::{collections::HashSet, time::Instant};
/// This is intended to be run locally against a running node.
///
/// This is a noop of env var `RETH_RPC_TEST_NODE_URL` is not set.
Expand All @@ -21,3 +22,28 @@ async fn trace_many_blocks() {
}
println!("Traced all blocks in {:?}", now.elapsed());
}

/// Tests the replaying of transactions on a local Ethereum node.

#[tokio::test(flavor = "multi_thread")]
async fn replay_transactions_() {
let url = parse_env_url("RETH_RPC_TEST_NODE_URL");
if url.is_err() {
return
}
let client = HttpClientBuilder::default().build(url.unwrap()).unwrap();

let tx_hashes = vec![
"0x4e08fe36db723a338e852f89f613e606b0c9a17e649b18b01251f86236a2cef3".parse().unwrap(),
"0xea2817f1aeeb587b82f4ab87a6dbd3560fc35ed28de1be280cb40b2a24ab48bb".parse().unwrap(),
];

let trace_types = HashSet::from([TraceType::StateDiff, TraceType::VmTrace]);

let mut stream = client.replay_transactions(tx_hashes, trace_types);
let now = Instant::now();
while let Some(replay_txs) = stream.next().await {
println!("Transaction: {:?}", replay_txs);
println!("Replayed transactions in {:?}", now.elapsed());
}
}
Loading