mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc-testing-utils) : make replay transactions reponses comparaison in RpcComparer. (#5407)
This commit is contained in:
committed by
GitHub
parent
2624f46675
commit
8100a88f9a
@ -22,5 +22,10 @@ futures.workspace = true
|
||||
jsonrpsee = { workspace = true, features = ["client", "async-client"] }
|
||||
serde_json.workspace = true
|
||||
|
||||
|
||||
# assertions
|
||||
similar-asserts = "1.5.0"
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "rt"] }
|
||||
|
||||
@ -447,8 +447,9 @@ where
|
||||
while let Some((result1, result2)) = zipped_streams.next().await {
|
||||
match (result1, result2) {
|
||||
(Ok((ref traces1_data, ref block1)), Ok((ref traces2_data, ref block2))) => {
|
||||
assert_eq!(
|
||||
traces1_data, traces2_data,
|
||||
similar_asserts::assert_eq!(
|
||||
traces1_data,
|
||||
traces2_data,
|
||||
"Mismatch in traces for block: {:?}",
|
||||
block1
|
||||
);
|
||||
@ -467,6 +468,43 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Compares the `replay_transactions` responses from the two RPC clients.
|
||||
pub async fn compare_replay_transaction_responses(
|
||||
&self,
|
||||
transaction_hashes: Vec<TxHash>,
|
||||
trace_types: HashSet<TraceType>,
|
||||
) {
|
||||
let stream1 =
|
||||
self.client1.replay_transactions(transaction_hashes.clone(), trace_types.clone());
|
||||
let stream2 = self.client2.replay_transactions(transaction_hashes, trace_types);
|
||||
|
||||
let mut zipped_streams = stream1.zip(stream2);
|
||||
|
||||
while let Some((result1, result2)) = zipped_streams.next().await {
|
||||
match (result1, result2) {
|
||||
(Ok((ref trace1_data, ref tx_hash1)), Ok((ref trace2_data, ref tx_hash2))) => {
|
||||
similar_asserts::assert_eq!(
|
||||
trace1_data,
|
||||
trace2_data,
|
||||
"Mismatch in trace results for transaction: {:?}",
|
||||
tx_hash1
|
||||
);
|
||||
assert_eq!(tx_hash1, tx_hash2, "Mismatch in transaction hashes.");
|
||||
}
|
||||
(Err((ref err1, ref tx_hash1)), Err((ref err2, ref tx_hash2))) => {
|
||||
assert_eq!(
|
||||
format!("{:?}", err1),
|
||||
format!("{:?}", err2),
|
||||
"Different errors for transaction: {:?}",
|
||||
tx_hash1
|
||||
);
|
||||
assert_eq!(tx_hash1, tx_hash2, "Mismatch in transaction hashes.");
|
||||
}
|
||||
_ => panic!("One client returned Ok while the other returned Err."),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
Reference in New Issue
Block a user