-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathissue_570.rs
More file actions
131 lines (104 loc) · 4.67 KB
/
Copy pathissue_570.rs
File metadata and controls
131 lines (104 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#![cfg(feature = "test-remote")]
use std::str::FromStr as _;
use edr_chain_config::{ChainOverride, HardforkActivations};
use edr_generic::GenericChainSpec;
use edr_primitives::B256;
use edr_provider::{
handlers::{RpcMethodCall, RpcRequest},
observability::ObservabilityConfig, Provider,
};
use edr_solidity::config::IncludeTraces;
use edr_test_utils::env::json_rpc_url_provider;
use serial_test::serial;
use crate::integration::helpers::get_chain_fork_provider;
// SAFETY: tests that modify the environment should be run serially.
fn get_provider() -> anyhow::Result<Provider<GenericChainSpec>> {
// Base Sepolia Testnet
const CHAIN_ID: u64 = 84532;
const BLOCK_NUMBER: u64 = 13_560_400;
let chain_override = ChainOverride {
name: "Base Sepolia".to_owned(),
hardfork_activation_overrides: Some(HardforkActivations::with_spec_id(
edr_chain_l1::Hardfork::CANCUN,
)),
};
let url = json_rpc_url_provider::base_sepolia();
get_chain_fork_provider::<GenericChainSpec>(
CHAIN_ID,
BLOCK_NUMBER,
chain_override,
url,
Some(ObservabilityConfig {
include_call_traces: IncludeTraces::All,
..ObservabilityConfig::default()
}),
)
}
// `eth_debugTraceTransaction` should return a helpful error message if there is
// a transaction in the block whose type is not supported.
// https://github.com/NomicFoundation/edr/issues/570
#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn issue_570_error_message() -> anyhow::Result<()> {
let provider = get_provider()?;
let transaction_hash =
B256::from_str("0xe565eb3bfd815efcc82bed1eef580117f9dc3d6896db42500572c8e789c5edd4")?;
let result = provider.handle_request(RpcRequest::with_single(
RpcMethodCall::with_params("debug_traceTransaction", (transaction_hash, Option::<serde_json::Value>::None)).expect("params should serialize"),
));
assert!(result.is_err());
let err_msg = result.unwrap_err().to_string();
assert!(
err_msg.contains("unsupported") || err_msg.contains("Unsupported"),
"Unexpected error: {err_msg}"
);
Ok(())
}
// `eth_debugTraceTransaction` should ignore transactions with unsupported types
// if a custom environment variable is set.
// https://github.com/NomicFoundation/edr/issues/570
#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn issue_570_env_var() -> anyhow::Result<()> {
// THIS CALL IS UNSAFE AND MIGHT LEAD TO UNDEFINED BEHAVIOR. WE DEEM THE RISK
// ACCEPTABLE FOR TESTING PURPOSES ONLY.
unsafe { std::env::set_var("__EDR_UNSAFE_SKIP_UNSUPPORTED_TRANSACTION_TYPES", "true") };
let provider = get_provider();
// THIS CALL IS UNSAFE AND MIGHT LEAD TO UNDEFINED BEHAVIOR. WE DEEM THE RISK
// ACCEPTABLE FOR TESTING PURPOSES ONLY.
unsafe { std::env::remove_var("__EDR_UNSAFE_SKIP_UNSUPPORTED_TRANSACTION_TYPES") };
let provider = provider?;
let transaction_hash =
B256::from_str("0xe565eb3bfd815efcc82bed1eef580117f9dc3d6896db42500572c8e789c5edd4")?;
let result = provider.handle_request(RpcRequest::with_single(
RpcMethodCall::with_params("debug_traceTransaction", (transaction_hash, Option::<serde_json::Value>::None)).expect("params should serialize"),
))?;
assert!(!result.call_trace_arenas.is_empty());
Ok(())
}
// `eth_debugTraceTransaction` should return a helpful error message if tracing
// is requested for a transaction with an unsupported type. https://github.com/NomicFoundation/edr/issues/570
#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn issue_570_unsupported_requested() -> anyhow::Result<()> {
// THIS CALL IS UNSAFE AND MIGHT LEAD TO UNDEFINED BEHAVIOR. WE DEEM THE RISK
// ACCEPTABLE FOR TESTING PURPOSES ONLY.
unsafe { std::env::set_var("__EDR_UNSAFE_SKIP_UNSUPPORTED_TRANSACTION_TYPES", "true") };
let provider = get_provider();
// THIS CALL IS UNSAFE AND MIGHT LEAD TO UNDEFINED BEHAVIOR. WE DEEM THE RISK
// ACCEPTABLE FOR TESTING PURPOSES ONLY.
unsafe { std::env::remove_var("__EDR_UNSAFE_SKIP_UNSUPPORTED_TRANSACTION_TYPES") };
let provider = provider?;
let transaction_hash =
B256::from_str("0xa9d8bf76337ac4a72a4085d5fd6456f6950b6b95d9d4aa198707a649268ef91c")?;
let result = provider.handle_request(RpcRequest::with_single(
RpcMethodCall::with_params("debug_traceTransaction", (transaction_hash, Option::<serde_json::Value>::None)).expect("params should serialize"),
));
assert!(result.is_err());
let err_msg = result.unwrap_err().to_string();
assert!(
err_msg.contains("unsupported") || err_msg.contains("Unsupported"),
"Unexpected error: {err_msg}"
);
Ok(())
}