revm_optimism/api/
default_ctx.rs1use crate::{L1BlockInfo, OpSpecId, OpTransaction};
2use revm::{
3 context::{BlockEnv, CfgEnv, TxEnv},
4 database_interface::EmptyDB,
5 Context, JournaledState, MainContext,
6};
7
8pub trait DefaultOp {
9 fn op() -> Context<
10 BlockEnv,
11 OpTransaction<TxEnv>,
12 CfgEnv<OpSpecId>,
13 EmptyDB,
14 JournaledState<EmptyDB>,
15 L1BlockInfo,
16 >;
17}
18
19impl DefaultOp
20 for Context<
21 BlockEnv,
22 OpTransaction<TxEnv>,
23 CfgEnv<OpSpecId>,
24 EmptyDB,
25 JournaledState<EmptyDB>,
26 L1BlockInfo,
27 >
28{
29 fn op() -> Self {
30 Context::mainnet()
31 .with_tx(OpTransaction::default())
32 .with_cfg(CfgEnv::new().with_spec(OpSpecId::BEDROCK))
33 .with_chain(L1BlockInfo::default())
34 }
35}
36
37#[cfg(test)]
38mod test {
39 use super::*;
40 use crate::api::builder::OpBuilder;
41 use inspector::{InspectEvm, NoOpInspector};
42 use revm::ExecuteEvm;
43
44 #[test]
45 fn default_run_op() {
46 let ctx = Context::op();
47 let mut evm = ctx.build_op_with_inspector(NoOpInspector {});
49 let _ = evm.transact_previous();
51 let _ = evm.inspect_previous();
53 }
54}