Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Dec 10, 2024
1 parent 7e79c24 commit 1575443
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions crates/starknet-os/src/hints/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn set_state_updates_start(
}?;

// TODO: check why compress_state_updates = 2 :/
let use_compress_state_updates = if compress_state_updates == Felt252::ONE { true } else { false };
let use_compress_state_updates = compress_state_updates == Felt252::ONE;

if use_kzg_da || use_compress_state_updates {
insert_value_from_var_name(vars::ids::STATE_UPDATES_START, vm.add_memory_segment(), vm, ids_data, ap_tracking)?;
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn set_n_updates_small(
constants: &HashMap<String, Felt252>,
) -> Result<(), HintError> {
let n_actual_updates = get_integer_from_var_name(vars::ids::N_ACTUAL_UPDATES, vm, ids_data, ap_tracking)?;
let n_updates_small_packing_bound = get_constant(&vars::ids::N_UPDATES_SMALL_PACKING_BOUND, constants)?;
let n_updates_small_packing_bound = get_constant(vars::ids::N_UPDATES_SMALL_PACKING_BOUND, constants)?;

let is_n_updates_small =
if n_actual_updates < *n_updates_small_packing_bound { Felt252::ONE } else { Felt252::ZERO };
Expand Down
38 changes: 20 additions & 18 deletions crates/starknet-os/src/io/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,26 +381,28 @@ mod tests {
Felt252::from(27),
],
messages_to_l2: vec![],
contracts: vec![ContractChanges {
addr: Felt252::ONE,
nonce: Felt252::from(100),
class_hash: None,
storage_changes: HashMap::from([
(
Felt252::from_hex_unchecked(
"0x723973208639b7839ce298f7ffea61e3f9533872defd7abdb91023db4658812",
state_diff: Some(OsStateDiff {
contract_changes: vec![ContractChanges {
addr: Felt252::ONE,
nonce: Felt252::from(100),
class_hash: None,
storage_changes: HashMap::from([
(
Felt252::from_hex_unchecked(
"0x723973208639b7839ce298f7ffea61e3f9533872defd7abdb91023db4658812",
),
Felt252::from_hex_unchecked("0x1f67eee3d0800"),
),
Felt252::from_hex_unchecked("0x1f67eee3d0800"),
),
(
Felt252::from_hex_unchecked(
"0x27e66af6f5df3e043d32367d68ece7e13645cca1ca9f80dfdaff9013fddf0c5",
(
Felt252::from_hex_unchecked(
"0x27e66af6f5df3e043d32367d68ece7e13645cca1ca9f80dfdaff9013fddf0c5",
),
Felt252::from_hex_unchecked("0xddec034b926f800"),
),
Felt252::from_hex_unchecked("0xddec034b926f800"),
),
]),
}],
classes: Default::default(),
]),
}],
classes: Default::default(),
}),
};

let os_output_str = serde_json::to_string(&os_output).expect("OS output serialization failed");
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ pub fn check_os_output_read_only_syscall(os_output: StarknetOsOutput, block_cont
// TODO: finer-grained contract changes checks
// Just check that the two contracts have been modified, these should be storage changes
// related to the fees.
assert_eq!(os_output.contracts.len(), 2);
assert!(os_output.state_diff.is_some());
let state_diff = os_output.state_diff.unwrap();
assert_eq!(state_diff.contract_changes.len(), 2);

assert_eq!(os_output.new_block_number.to_u64().unwrap(), block_context.block_info().block_number.0);
assert!(os_output.classes.is_empty());
assert!(state_diff.classes.is_empty());
assert!(os_output.messages_to_l1.is_empty());
assert!(os_output.messages_to_l2.is_empty());
let use_kzg_da = os_output.use_kzg_da != Felt252::ZERO;
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/deprecated_syscalls_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,12 @@ async fn test_syscall_get_tx_info_cairo0(
.await
.expect("OS run failed");

assert!(os_output.state_diff.is_some());
let state_diff = os_output.state_diff.unwrap();

// This test causes storage changes in the test contract. Check them.
let contract_changes_by_address: HashMap<_, _> =
os_output.contracts.iter().map(|change| (change.addr, change)).collect();
state_diff.contract_changes.iter().map(|change| (change.addr, change)).collect();
let test_contract_changes = contract_changes_by_address
.get(contract_address.0.key())
.expect("The test contract should appear as modified in the OS output");
Expand Down Expand Up @@ -391,14 +394,17 @@ async fn test_syscall_deploy_cairo0(
.await
.expect("OS run failed");

assert!(os_output.state_diff.is_some());
let state_diff = os_output.state_diff.unwrap();

// Check that the new contract address appears in the OS output
let contract_changes_by_address: HashMap<_, _> =
os_output.contracts.iter().map(|change| (change.addr, change)).collect();
state_diff.contract_changes.iter().map(|change| (change.addr, change)).collect();
assert!(contract_changes_by_address.contains_key(expected_contract_address.key()));

// Check other output fields
assert_eq!(os_output.new_block_number.to_u64().unwrap(), block_context.block_info().block_number.0);
assert!(os_output.classes.is_empty());
assert!(state_diff.classes.is_empty());
assert!(os_output.messages_to_l1.is_empty());
assert!(os_output.messages_to_l2.is_empty());
let use_kzg_da = os_output.use_kzg_da != Felt252::ZERO;
Expand Down

0 comments on commit 1575443

Please sign in to comment.