Skip to content
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
25 changes: 13 additions & 12 deletions crates/apollo_integration_tests/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,22 @@ fn get_total_batched_txs_count(recorder_handle: &PrometheusHandle) -> usize {
}

fn assert_full_blocks_flow(recorder_handle: &PrometheusHandle, expecting_full_blocks: bool) {
let metrics = recorder_handle.render();
let full_blocks_metric = apollo_batcher::metrics::BLOCK_CLOSE_REASON
.parse_numeric_metric::<u64>(
&metrics,
&[(
apollo_batcher::metrics::LABEL_NAME_BLOCK_CLOSE_REASON,
apollo_batcher::metrics::BlockCloseReason::FullBlock.into(),
)],
)
.unwrap();
if expecting_full_blocks {
let metrics = recorder_handle.render();
let full_blocks_metric = apollo_batcher::metrics::BLOCK_CLOSE_REASON
.parse_numeric_metric::<u64>(
&metrics,
&[(
apollo_batcher::metrics::LABEL_NAME_BLOCK_CLOSE_REASON,
apollo_batcher::metrics::BlockCloseReason::FullBlock.into(),
)],
)
.unwrap();
assert!(full_blocks_metric > 0);
} else {
assert_eq!(full_blocks_metric, 0);
}
// Just because we don't expect full blocks, doesn't mean we should assert that the metric is 0.
// It is possible that a block is filled, no need to assert that this is not the case.
// TODO(AlonH): In the `else` case, assert that some block closed due to time.
}

fn assert_no_reverted_transactions_flow(recorder_handle: &PrometheusHandle) {
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/bouncer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,11 @@ fn class_hash_migration_data_from_state(

if should_migrate {
expect![[r#"
90624924
102613834
"#]]
.assert_debug_eq(&migration_sierra_gas.0);
expect![[r#"
219546600
249398680
"#]]
.assert_debug_eq(&migration_proving_gas.0);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub const REQUIRED_GAS_GET_BLOCK_HASH_TEST: u64 = 14920;
pub const REQUIRED_GAS_GET_BLOCK_HASH_TEST: u64 = 16220;
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn positive_flow(runnable_version: RunnableCairo1) {
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
let (mut state, block_number, block_hash) = initialize_state(test_contract);

let calldata = calldata![block_number];
let calldata = calldata![block_number, block_hash];
let entry_point_call = CallEntryPoint {
entry_point_selector: selector_from_name("test_get_block_hash"),
calldata,
Expand Down Expand Up @@ -83,7 +83,7 @@ fn positive_flow(runnable_version: RunnableCairo1) {
l2_to_l1_messages: [],
cairo_native: false,
failed: false,
gas_consumed: 14920,
gas_consumed: 15620,
}
"#]]
.assert_debug_eq(&call_info.execution);
Expand All @@ -98,7 +98,8 @@ fn negative_flow_block_number_out_of_range(runnable_version: RunnableCairo1) {

let requested_block_number = CURRENT_BLOCK_NUMBER - constants::STORED_BLOCK_HASH_BUFFER + 1;
let block_number = felt!(requested_block_number);
let calldata = calldata![block_number];
let dummy_block_hash = felt!(66_u64);
let calldata = calldata![block_number, dummy_block_hash];
let entry_point_call = CallEntryPoint {
entry_point_selector: selector_from_name("test_get_block_hash"),
calldata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1)]);
let address = contract_address!("0x111");
let class_hash = class_hash!("0x222");
let class_hash_of_undeployed_contract = felt!("0x0");
let non_existing_address = felt!("0x333");
state.state.address_to_class_hash.insert(address, class_hash);

// Test deployed contract.
let positive_entry_point_call = CallEntryPoint {
calldata: calldata![address.into(), class_hash.0],
calldata: calldata![address.into(), class_hash.0, non_existing_address],
entry_point_selector: selector_from_name("test_get_class_hash_at"),
..trivial_external_entry_point_new(test_contract)
};
Expand All @@ -51,18 +53,20 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
l2_to_l1_messages: [],
cairo_native: false,
failed: false,
gas_consumed: 15960,
gas_consumed: 28370,
}
"#]]
.assert_debug_eq(&positive_call_info.execution);
assert!(!positive_call_info.execution.failed);
assert_eq!(positive_call_info.execution.retdata, retdata![]);
// Test undeployed contract - should return class_hash = 0 and succeed.
let non_existing_address = felt!("0x333");
let class_hash_of_undeployed_contract = felt!("0x0");

// Test undeployed contract - should return class_hash = 0 and succeed.
let negative_entry_point_call = CallEntryPoint {
calldata: calldata![non_existing_address, class_hash_of_undeployed_contract],
calldata: calldata![
non_existing_address,
class_hash_of_undeployed_contract,
non_existing_address
],
entry_point_selector: selector_from_name("test_get_class_hash_at"),
..trivial_external_entry_point_new(test_contract)
};
Expand All @@ -71,7 +75,7 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
// Sanity check: giving the wrong expected class hash to the test should make it fail.
let different_class_hash = class_hash!("0x444");
let different_class_hash_entry_point_call = CallEntryPoint {
calldata: calldata![address.into(), different_class_hash.0],
calldata: calldata![address.into(), different_class_hash.0, non_existing_address],
entry_point_selector: selector_from_name("test_get_class_hash_at"),
..trivial_external_entry_point_new(test_contract)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::test_utils::trivial_external_entry_point_new;
#[test_case(RunnableCairo1::Casm; "VM")]
fn test_out_of_gas(runnable_version: RunnableCairo1) {
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
let (mut state, block_number, _block_hash) = initialize_state(test_contract);
let (mut state, block_number, block_hash) = initialize_state(test_contract);

let calldata = calldata![block_number];
let calldata = calldata![block_number, block_hash];
let entry_point_call = CallEntryPoint {
entry_point_selector: selector_from_name("test_get_block_hash"),
calldata,
Expand Down
Loading
Loading