Skip to content

Commit da97811

Browse files
starknet_os_flow_tests: add flow test for inner deploy cairo1 revert
Signed-off-by: Dori Medini <dori@starkware.co>
1 parent e07082d commit da97811

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

crates/blockifier/src/bouncer_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,11 @@ fn class_hash_migration_data_from_state(
777777

778778
if should_migrate {
779779
expect![[r#"
780-
99939035
780+
102668921
781781
"#]]
782782
.assert_debug_eq(&migration_sierra_gas.0);
783783
expect![[r#"
784-
260040060
784+
266906050
785785
"#]]
786786
.assert_debug_eq(&migration_proving_gas.0);
787787
} else {

crates/starknet_os_flow_tests/src/tests.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,44 @@ async fn test_deploy_syscall() {
19931993
);
19941994
}
19951995

1996+
#[rstest]
1997+
#[tokio::test]
1998+
async fn test_inner_deploy_failure() {
1999+
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm));
2000+
let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm));
2001+
let (mut test_manager, [test_contract_address, _empty_contract_address]) =
2002+
TestManager::<DictStateReader>::new_with_default_initial_state([
2003+
(test_contract, calldata![Felt::ZERO, Felt::ZERO]),
2004+
(empty_contract, calldata![]),
2005+
])
2006+
.await;
2007+
2008+
// Precompute the expected deploy address of the new empty contract instance.
2009+
let salt = ContractAddressSalt(Felt::from(127));
2010+
let empty_class_hash = get_class_hash_of_feature_contract(empty_contract);
2011+
let expected_deploy_address =
2012+
calculate_contract_address(salt, empty_class_hash, &calldata![], test_contract_address)
2013+
.unwrap();
2014+
2015+
let calldata = create_calldata(
2016+
test_contract_address,
2017+
"test_get_class_hash_after_failed_deploy",
2018+
&[
2019+
empty_class_hash.0,
2020+
**test_contract_address,
2021+
selector_from_name("deploy_and_fail").0,
2022+
salt.0,
2023+
**expected_deploy_address,
2024+
],
2025+
);
2026+
test_manager.add_funded_account_invoke(invoke_tx_args! { calldata });
2027+
2028+
// Run the test and verify storage changes.
2029+
let test_output =
2030+
test_manager.execute_test_with_default_block_contexts(&TestParameters::default()).await;
2031+
test_output.perform_default_validations();
2032+
}
2033+
19962034
#[rstest]
19972035
#[tokio::test]
19982036
async fn test_block_info(#[values(true, false)] is_cairo0: bool) {

0 commit comments

Comments
 (0)