Skip to content

Commit 5bcebdf

Browse files
committed
fix: bytes
1 parent 37872ba commit 5bcebdf

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/builder.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ impl<Db, Insp> TrevmBuilder<Db, Insp> {
4545
}
4646

4747
/// Set the inspector for the EVM.
48+
///
49+
/// Equivalent to [`Self::with_inspector`].
4850
pub fn with_insp<OInsp>(self, insp: OInsp) -> TrevmBuilder<Db, OInsp> {
4951
TrevmBuilder { db: self.db, insp, spec: self.spec, precompiles: self.precompiles }
5052
}
5153

54+
/// Set the inspector for the EVM.
55+
///
56+
/// Equivalent to [`Self::with_insp`].
57+
pub fn with_inspector<OInsp>(self, insp: OInsp) -> TrevmBuilder<Db, OInsp> {
58+
self.with_insp(insp)
59+
}
60+
5261
/// Set the spec id for the EVM.
5362
pub const fn with_spec_id(mut self, spec: SpecId) -> Self {
5463
self.spec = spec;

src/evm.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,22 +2348,21 @@ where
23482348

23492349
#[cfg(test)]
23502350
mod tests {
2351+
use super::*;
2352+
use crate::{
2353+
test_utils::{test_trevm_with_funds, ALICE, BOB, LOG_DEPLOYED_BYTECODE},
2354+
NoopBlock, NoopCfg, TrevmBuilder,
2355+
};
23512356
use alloy::{
2357+
consensus::constants::ETH_TO_WEI,
23522358
network::{TransactionBuilder, TransactionBuilder7702},
23532359
rpc::types::{Authorization, TransactionRequest},
23542360
signers::SignerSync,
2355-
consensus::constants::ETH_TO_WEI,
23562361
};
23572362
use revm::{
2358-
context::transaction::AuthorizationTr,
2359-
database::InMemoryDB,
2360-
primitives::bytes,
2361-
};
2362-
use crate::{
2363-
test_utils::{test_trevm_with_funds, ALICE, BOB, LOG_BYTECODE},
2364-
TrevmBuilder, NoopBlock, NoopCfg,
2363+
context::transaction::AuthorizationTr, database::InMemoryDB,
2364+
inspector::inspectors::TracerEip3155, primitives::bytes,
23652365
};
2366-
use super::*;
23672366

23682367
#[test]
23692368
fn test_estimate_gas_simple_transfer() {
@@ -2395,7 +2394,7 @@ mod tests {
23952394
let mut trevm =
23962395
TrevmBuilder::new().with_db(db).with_spec_id(SpecId::PRAGUE).build_trevm().unwrap();
23972396
let _ = trevm.test_set_balance(ALICE.address(), U256::from(ETH_TO_WEI));
2398-
let _ = trevm.set_bytecode_unchecked(log_address, Bytecode::new_raw(LOG_BYTECODE.into()));
2397+
let _ = trevm.set_bytecode_unchecked(log_address, Bytecode::new_raw(LOG_DEPLOYED_BYTECODE));
23992398

24002399
// Bob will sign the authorization.
24012400
let authorization = Authorization {
@@ -2417,6 +2416,7 @@ mod tests {
24172416
let (estimation, trevm) =
24182417
trevm.fill_cfg(&NoopCfg).fill_block(&NoopBlock).fill_tx(&tx).estimate_gas().unwrap();
24192418

2419+
dbg!(&estimation);
24202420
assert!(estimation.is_success());
24212421

24222422
let tx = tx.with_gas_limit(estimation.limit());

src/test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use revm::{
1212
interpreter::{
1313
CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, InterpreterTypes,
1414
},
15-
primitives::{hardfork::SpecId, Log},
15+
primitives::{bytes, hardfork::SpecId, Log},
1616
state::AccountInfo,
1717
Context, Inspector, MainBuilder,
1818
};
1919

2020
/// LogContract bytecode
2121
/// This is the runtime bytecode. This should be set directly with ``set_bytecode_unchecked``
22-
/// ```no_run
22+
/// ```ignore
2323
/// contract LogContract {
2424
/// event Hello();
2525
/// event World();
@@ -33,7 +33,7 @@ use revm::{
3333
/// }
3434
/// }
3535
/// ```
36-
pub const LOG_BYTECODE: &str = "0x6004361015600b575f80fd5b5f3560e01c80637b3ab2d014605f57639ee1a440146027575f80fd5b34605b575f366003190112605b577f2d67bb91f17bca05af6764ab411e86f4ddf757adb89fcec59a7d21c525d417125f80a1005b5f80fd5b34605b575f366003190112605b577fbcdfe0d5b27dd186282e187525415c57ea3077c34efb39148111e4d342e7ab0e5f80a100fea2646970667358221220f6b42b522bc9fb2b4c7d7e611c7c3e995d057ecab7fd7be4179712804c886b4f64736f6c63430008190033";
36+
pub const LOG_DEPLOYED_BYTECODE: alloy::primitives::Bytes = bytes!("6080604052348015600e575f80fd5b50600436106030575f3560e01c80637b3ab2d01460345780639ee1a44014603c575b5f80fd5b603a6044565b005b60426072565b005b7fbcdfe0d5b27dd186282e187525415c57ea3077c34efb39148111e4d342e7ab0e60405160405180910390a1565b7f2d67bb91f17bca05af6764ab411e86f4ddf757adb89fcec59a7d21c525d4171260405160405180910390a156fea2646970667358221220144b313f421e29c7119666392827595d05f3dc33d0ccb0e75314cc9180e4fb1f64736f6c634300081a0033");
3737

3838
/// Alice testing signer
3939
pub static ALICE: LazyLock<PrivateKeySigner> =

0 commit comments

Comments
 (0)