Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ mod test {
block_context.starknet_os_config.gas_price = 1;

let estimated_fee = estimate_message_fee(&l1_handler, state, &block_context).unwrap();
assert_eq!(estimated_fee, (19708, 19695));
assert_eq!(estimated_fee, (19709, 19695));
}

#[test]
Expand Down
25 changes: 18 additions & 7 deletions src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ impl ExecutionResourcesManager {
}
}

pub fn increment_syscall_counter(&mut self, syscall_name: &str, amount: u64) -> Option<()> {
self.syscall_counter
.get_mut(syscall_name)
.map(|val| *val += amount)
pub fn increment_syscall_counter(&mut self, syscall_name: &str, amount: u64) {
*self
.syscall_counter
.entry(syscall_name.to_string())
.or_default() += amount
}

pub fn get_syscall_counter(&self, syscall_name: &str) -> Option<u64> {
Expand Down Expand Up @@ -294,9 +295,7 @@ mod test {
Default::default(),
);

execution_resources_manager
.increment_syscall_counter("syscall1", 1)
.unwrap();
execution_resources_manager.increment_syscall_counter("syscall1", 1);

assert_eq!(
execution_resources_manager.get_syscall_counter("syscall1"),
Expand All @@ -308,6 +307,18 @@ mod test {
);
}

#[test]
fn execution_resources_manager_should_add_syscall_if_not_present() {
let mut execution_resources_manager = super::ExecutionResourcesManager::default();

execution_resources_manager.increment_syscall_counter("syscall1", 1);

assert_eq!(
execution_resources_manager.get_syscall_counter("syscall1"),
Some(1)
);
}

#[test]
fn state_diff_to_cached_state_should_return_correct_cached_state() {
let mut state_reader = InMemoryStateReader::default();
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ mod test {
fee_transfer_info: None,
actual_fee: 0,
actual_resources: HashMap::from([
("n_steps".to_string(), 1229),
("n_steps".to_string(), 1319),
("pedersen_builtin".to_string(), 13),
("range_check_builtin".to_string(), 23),
("l1_gas_usage".to_string(), 19695),
Expand Down
4 changes: 2 additions & 2 deletions tests/deploy_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ fn internal_deploy_account_cairo1() {
let n_steps;
#[cfg(not(feature = "cairo_1_tests"))]
{
n_steps = 3873;
n_steps = 3948;
}
#[cfg(feature = "cairo_1_tests")]
{
n_steps = 3877;
n_steps = 3952;
}

assert_eq!(
Expand Down
10 changes: 5 additions & 5 deletions tests/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,10 +1224,10 @@ fn expected_fib_validate_call_info_2() -> CallInfo {

fn expected_transaction_execution_info(block_context: &BlockContext) -> TransactionExecutionInfo {
let resources = HashMap::from([
("n_steps".to_string(), 3445),
("n_steps".to_string(), 4135),
("pedersen_builtin".to_string(), 16),
("l1_gas_usage".to_string(), 2448),
("range_check_builtin".to_string(), 82),
("range_check_builtin".to_string(), 101),
]);
let fee = calculate_tx_fee(&resources, *GAS_PRICE, block_context).unwrap();
TransactionExecutionInfo::new(
Expand All @@ -1247,17 +1247,17 @@ fn expected_fib_transaction_execution_info(
let n_steps;
#[cfg(not(feature = "cairo_1_tests"))]
{
n_steps = 3541;
n_steps = 4231;
}
#[cfg(feature = "cairo_1_tests")]
{
n_steps = 3544;
n_steps = 4234;
}
let resources = HashMap::from([
("n_steps".to_string(), n_steps),
("l1_gas_usage".to_string(), 7344),
("pedersen_builtin".to_string(), 16),
("range_check_builtin".to_string(), 85),
("range_check_builtin".to_string(), 104),
]);
let fee = calculate_tx_fee(&resources, *GAS_PRICE, block_context).unwrap();
TransactionExecutionInfo::new(
Expand Down