Skip to content

Commit

Permalink
refactor(blockifier): replace BouncerConfig default by create_for_tes…
Browse files Browse the repository at this point in the history
…ting (#1283)
  • Loading branch information
ayeletstarkware authored Oct 10, 2024
1 parent 72a16a7 commit 8fa8073
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/blockifier/src/blockifier/transaction_executor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn test_l1_handler(block_context: BlockContext) {
}

#[rstest]
#[case::happy_flow(BouncerWeights::default(), 10)]
#[case::happy_flow(BouncerWeights::empty(), 10)]
#[should_panic(expected = "BlockFull: Transaction cannot be added to the current block, block \
capacity reached.")]
#[case::block_full(
Expand All @@ -250,7 +250,7 @@ fn test_l1_handler(block_context: BlockContext) {
7
)]
#[should_panic(expected = "Transaction size exceeds the maximum block capacity.")]
#[case::transaction_too_large(BouncerWeights::default(), 11)]
#[case::transaction_too_large(BouncerWeights::empty(), 11)]

fn test_bouncing(#[case] initial_bouncer_weights: BouncerWeights, #[case] n_events: usize) {
let max_n_events_in_block = 10;
Expand Down
4 changes: 0 additions & 4 deletions crates/blockifier/src/bouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ impl BouncerConfig {
Self { block_max_capacity: BouncerWeights::max() }
}

pub fn empty() -> Self {
Self::default()
}

pub fn has_room(&self, weights: BouncerWeights) -> bool {
self.block_max_capacity.has_room(weights)
}
Expand Down
21 changes: 20 additions & 1 deletion crates/blockifier/src/test_utils/struct_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::update_json_value;
use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants;
use crate::blockifier::block::{BlockInfo, BlockNumberHashPair, GasPrices};
use crate::bouncer::{BouncerConfig, BouncerWeights};
use crate::bouncer::{BouncerConfig, BouncerWeights, BuiltinCount};
use crate::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext};
use crate::execution::call_info::{CallExecution, CallInfo, Retdata};
use crate::execution::contract_class::{ContractClassV0, ContractClassV1};
Expand Down Expand Up @@ -278,3 +278,22 @@ impl L1HandlerTransaction {
Self { tx, tx_hash, paid_fee_on_l1: l1_fee }
}
}

impl BouncerConfig {
pub fn empty() -> Self {
Self { block_max_capacity: BouncerWeights::empty() }
}
}

impl BouncerWeights {
pub fn empty() -> Self {
Self {
n_events: 0,
builtin_count: BuiltinCount::default(),
gas: 0,
message_segment_length: 0,
n_steps: 0,
state_diff_size: 0,
}
}
}

0 comments on commit 8fa8073

Please sign in to comment.