Skip to content

Commit 088c95f

Browse files
blockifier: update test contract for test_new_contract_flow
1 parent 58b04e7 commit 088c95f

File tree

8 files changed

+33271
-23717
lines changed

8 files changed

+33271
-23717
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub const REQUIRED_GAS_GET_BLOCK_HASH_TEST: u64 = 15220;
1+
pub const REQUIRED_GAS_GET_BLOCK_HASH_TEST: u64 = 16720;

crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn positive_flow(runnable_version: RunnableCairo1) {
4848
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
4949
let (mut state, block_number, block_hash) = initialize_state(test_contract);
5050

51-
let calldata = calldata![block_number];
51+
let calldata = calldata![block_number, block_hash];
5252
let entry_point_call = CallEntryPoint {
5353
entry_point_selector: selector_from_name("test_get_block_hash"),
5454
calldata,
@@ -83,7 +83,7 @@ fn positive_flow(runnable_version: RunnableCairo1) {
8383
l2_to_l1_messages: [],
8484
cairo_native: false,
8585
failed: false,
86-
gas_consumed: 15220,
86+
gas_consumed: 16020,
8787
}
8888
"#]]
8989
.assert_debug_eq(&call_info.execution);
@@ -98,7 +98,8 @@ fn negative_flow_block_number_out_of_range(runnable_version: RunnableCairo1) {
9898

9999
let requested_block_number = CURRENT_BLOCK_NUMBER - constants::STORED_BLOCK_HASH_BUFFER + 1;
100100
let block_number = felt!(requested_block_number);
101-
let calldata = calldata![block_number];
101+
let dummy_block_hash = felt!(66_u64);
102+
let calldata = calldata![block_number, dummy_block_hash];
102103
let entry_point_call = CallEntryPoint {
103104
entry_point_selector: selector_from_name("test_get_block_hash"),
104105
calldata,

crates/blockifier/src/execution/syscalls/syscall_tests/get_class_hash_at.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
2525
let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1)]);
2626
let address = contract_address!("0x111");
2727
let class_hash = class_hash!("0x222");
28+
let class_hash_of_undeployed_contract = felt!("0x0");
29+
let non_existing_address = felt!("0x333");
2830
state.state.address_to_class_hash.insert(address, class_hash);
2931

3032
// Test deployed contract.
3133
let positive_entry_point_call = CallEntryPoint {
32-
calldata: calldata![address.into(), class_hash.0],
34+
calldata: calldata![address.into(), class_hash.0, non_existing_address],
3335
entry_point_selector: selector_from_name("test_get_class_hash_at"),
3436
..trivial_external_entry_point_new(test_contract)
3537
};
@@ -51,18 +53,20 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
5153
l2_to_l1_messages: [],
5254
cairo_native: false,
5355
failed: false,
54-
gas_consumed: 16460,
56+
gas_consumed: 29070,
5557
}
5658
"#]]
5759
.assert_debug_eq(&positive_call_info.execution);
5860
assert!(!positive_call_info.execution.failed);
5961
assert_eq!(positive_call_info.execution.retdata, retdata![]);
60-
// Test undeployed contract - should return class_hash = 0 and succeed.
61-
let non_existing_address = felt!("0x333");
62-
let class_hash_of_undeployed_contract = felt!("0x0");
6362

63+
// Test undeployed contract - should return class_hash = 0 and succeed.
6464
let negative_entry_point_call = CallEntryPoint {
65-
calldata: calldata![non_existing_address, class_hash_of_undeployed_contract],
65+
calldata: calldata![
66+
non_existing_address,
67+
class_hash_of_undeployed_contract,
68+
non_existing_address
69+
],
6670
entry_point_selector: selector_from_name("test_get_class_hash_at"),
6771
..trivial_external_entry_point_new(test_contract)
6872
};
@@ -71,7 +75,7 @@ fn test_get_class_hash_at(runnable_version: RunnableCairo1) {
7175
// Sanity check: giving the wrong expected class hash to the test should make it fail.
7276
let different_class_hash = class_hash!("0x444");
7377
let different_class_hash_entry_point_call = CallEntryPoint {
74-
calldata: calldata![address.into(), different_class_hash.0],
78+
calldata: calldata![address.into(), different_class_hash.0, non_existing_address],
7579
entry_point_selector: selector_from_name("test_get_class_hash_at"),
7680
..trivial_external_entry_point_new(test_contract)
7781
};

crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use crate::test_utils::trivial_external_entry_point_new;
1818
#[test_case(RunnableCairo1::Casm; "VM")]
1919
fn test_out_of_gas(runnable_version: RunnableCairo1) {
2020
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version));
21-
let (mut state, block_number, _block_hash) = initialize_state(test_contract);
21+
let (mut state, block_number, block_hash) = initialize_state(test_contract);
2222

23-
let calldata = calldata![block_number];
23+
let calldata = calldata![block_number, block_hash];
2424
let entry_point_call = CallEntryPoint {
2525
entry_point_selector: selector_from_name("test_get_block_hash"),
2626
calldata,

0 commit comments

Comments
 (0)