Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/rpc/rpc-convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ thiserror.workspace = true
auto_impl.workspace = true
dyn-clone.workspace = true

[dev-dependencies]
serde_json.workspace = true

[features]
default = []
op = [
Expand Down
20 changes: 20 additions & 0 deletions crates/rpc/rpc-convert/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ mod transaction_response_tests {
use alloy_network::Ethereum;
use alloy_primitives::{Address, Signature, B256, U256};
use alloy_rpc_types_eth::Transaction;
use op_revm::transaction::OpTxTr;

#[test]
fn test_ethereum_transaction_conversion() {
Expand Down Expand Up @@ -1155,4 +1156,23 @@ mod transaction_response_tests {

assert!(result.is_ok());
}

#[cfg(feature = "op")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to wrap it in a feature gated module so that the test and the usage statement need just one feature gate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, done

#[test]
fn test_op_into_tx_env() {
use op_alloy_rpc_types::OpTransactionRequest;
use op_revm::OpSpecId;
use revm_context::Transaction;

let s = r#"{"from":"0x0000000000000000000000000000000000000000","to":"0x6d362b9c3ab68c0b7c79e8a714f1d7f3af63655f","input":"0x1626ba7ec8ee0d506e864589b799a645ddb88b08f5d39e8049f9f702b3b61fa15e55fc73000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000550000002d6db27c52e3c11c1cf24072004ac75cba49b25bf45f513902e469755e1f3bf2ca8324ad16930b0a965c012a24bb1101f876ebebac047bd3b6bf610205a27171eaaeffe4b5e5589936f4e542d637b627311b0000000000000000000000","data":"0x1626ba7ec8ee0d506e864589b799a645ddb88b08f5d39e8049f9f702b3b61fa15e55fc73000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000550000002d6db27c52e3c11c1cf24072004ac75cba49b25bf45f513902e469755e1f3bf2ca8324ad16930b0a965c012a24bb1101f876ebebac047bd3b6bf610205a27171eaaeffe4b5e5589936f4e542d637b627311b0000000000000000000000","chainId":"0x7a69"}"#;

let req: OpTransactionRequest = serde_json::from_str(s).unwrap();

let cfg = CfgEnv::<OpSpecId>::default();
let block_env = BlockEnv::default();
let tx_env = req.try_into_tx_env(&cfg, &block_env).unwrap();
assert_eq!(tx_env.gas_limit(), block_env.gas_limit);
assert_eq!(tx_env.gas_price(), 0);
assert!(tx_env.enveloped_tx().unwrap().is_empty());
}
}
Loading