Skip to content

Commit

Permalink
refactor(execution): change get fee token blance in state api to get …
Browse files Browse the repository at this point in the history
…&self and not &mut self (#134)
  • Loading branch information
meship-starkware authored Jul 29, 2024
1 parent 66e7f0c commit 5511419
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/src/state/state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait StateReader {
// TODO(Dori, 1/9/2023): NEW_TOKEN_SUPPORT Determine fee token address based on tx version,
// once v3 is introduced.
fn get_fee_token_balance(
&mut self,
&self,
contract_address: ContractAddress,
fee_token_address: ContractAddress,
) -> Result<(Felt, Felt), StateError> {
Expand Down
28 changes: 8 additions & 20 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn create_flavors_test_state(
/// Returns the new balance.
fn check_balance<S: StateReader>(
current_balance: Felt,
state: &mut CachedState<S>,
state: &CachedState<S>,
account_address: ContractAddress,
chain_info: &ChainInfo,
fee_type: &FeeType,
Expand Down Expand Up @@ -469,7 +469,7 @@ fn test_simulate_validate_charge_fee_mid_execution(
);
let current_balance = check_balance(
current_balance,
&mut state,
&state,
account_address,
&block_context.chain_info,
&fee_type,
Expand Down Expand Up @@ -518,14 +518,8 @@ fn test_simulate_validate_charge_fee_mid_execution(
// charged final fee is shown in actual_fee.
if charge_fee { limited_fee } else { unlimited_fee },
);
let current_balance = check_balance(
current_balance,
&mut state,
account_address,
chain_info,
&fee_type,
charge_fee,
);
let current_balance =
check_balance(current_balance, &state, account_address, chain_info, &fee_type, charge_fee);

// Third scenario: only limit is block bounds. Expect resources consumed to be identical,
// whether or not `charge_fee` is true.
Expand Down Expand Up @@ -564,7 +558,7 @@ fn test_simulate_validate_charge_fee_mid_execution(
block_limit_fee,
block_limit_fee,
);
check_balance(current_balance, &mut state, account_address, chain_info, &fee_type, charge_fee);
check_balance(current_balance, &state, account_address, chain_info, &fee_type, charge_fee);
}

#[rstest]
Expand Down Expand Up @@ -652,14 +646,8 @@ fn test_simulate_validate_charge_fee_post_execution(
if charge_fee { just_not_enough_fee_bound } else { unlimited_fee },
if charge_fee { revert_fee } else { unlimited_fee },
);
let current_balance = check_balance(
current_balance,
&mut state,
account_address,
chain_info,
&fee_type,
charge_fee,
);
let current_balance =
check_balance(current_balance, &state, account_address, chain_info, &fee_type, charge_fee);

// Second scenario: balance too low.
// Execute a transfer, and make sure we get the expected result.
Expand Down Expand Up @@ -724,7 +712,7 @@ fn test_simulate_validate_charge_fee_post_execution(
);
check_balance(
current_balance,
&mut state,
&state,
account_address,
chain_info,
&fee_type,
Expand Down

0 comments on commit 5511419

Please sign in to comment.