Skip to content

Commit f40e4a2

Browse files
apollo_integration_tests: add regression tests for matching the proof generation
1 parent 8c37711 commit f40e4a2

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

crates/apollo_integration_tests/src/state_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn initialize_papyrus_test_state(
376376
}
377377

378378
/// Global root that matches the proof flow fixtures.
379-
fn integration_test_genesis_global_root() -> GlobalRoot {
379+
pub fn integration_test_genesis_global_root() -> GlobalRoot {
380380
GlobalRoot(felt!("0x68fed6a062d385db8d1dd9096060e822196feb311fc3bb4f0018635461ca85e"))
381381
}
382382

crates/starknet_os_flow_tests/src/virtual_os_test.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use std::path::Path;
22

3+
use apollo_integration_tests::state_reader::{
4+
integration_test_genesis_global_root,
5+
proof_flow_chain_info,
6+
};
37
use blockifier::execution::contract_class::TrackedResource;
48
use blockifier::test_utils::dict_state_reader::DictStateReader;
59
use blockifier::test_utils::get_valid_virtual_os_program_hash;
@@ -11,6 +15,7 @@ use rstest::rstest;
1115
use starknet_api::abi::abi_utils::selector_from_name;
1216
use starknet_api::block::{BlockInfo, BlockNumber, BlockTimestamp};
1317
use starknet_api::core::EthAddress;
18+
use starknet_api::hash::StateRoots;
1419
use starknet_api::test_utils::{CURRENT_BLOCK_TIMESTAMP, TEST_SEQUENCER_ADDRESS};
1520
use starknet_api::transaction::fields::{ProofFacts, TransactionSignature};
1621
use starknet_api::transaction::{
@@ -22,7 +27,9 @@ use starknet_api::transaction::{
2227
use starknet_api::{calldata, contract_address, invoke_tx_args};
2328
use starknet_types_core::felt::Felt;
2429

30+
use crate::initial_state::create_default_initial_state_data;
2531
use crate::test_manager::{
32+
block_context_for_flow_tests,
2633
EventPredicateExpectation,
2734
TestBuilder,
2835
TestBuilderConfig,
@@ -308,3 +315,42 @@ async fn generate_proof_fixtures() {
308315
.expect("write proof_facts.json");
309316
std::fs::write(&proof_path, output.proof.0.as_slice()).expect("write proof.bin");
310317
}
318+
319+
/// Guards against drift between the chain info used by the proof-flow integration test.
320+
#[test]
321+
fn proof_flow_chain_info_matches_virtual_os_test() {
322+
let virtual_os_chain_info =
323+
block_context_for_flow_tests(BlockNumber(0), false).chain_info().clone();
324+
let integration_test_chain_info = proof_flow_chain_info();
325+
assert_eq!(
326+
virtual_os_chain_info.fee_token_addresses.strk_fee_token_address,
327+
integration_test_chain_info.fee_token_addresses.strk_fee_token_address,
328+
"The proof flow integration test uses a different STRK fee token address than the virtual \
329+
OS test. Please update the STRK fee token address in the proof flow integration test to \
330+
match the virtual OS test and regenerate the proof fixtures (run `cargo \
331+
+nightly-2025-07-14 test -p starknet_os_flow_tests --features stwo_proving --release \
332+
generate_proof_fixtures -- --ignored`).",
333+
);
334+
}
335+
336+
/// Guards against drift between the genesis global root the proof-flow integration test seeds into
337+
/// storage and the initial global root produced used to generate the proof fixtures.
338+
#[tokio::test(flavor = "multi_thread")]
339+
async fn proof_flow_global_root_matches_virtual_os_test() {
340+
let (initial_state_data, []) =
341+
create_default_initial_state_data::<DictStateReader, 0>([]).await;
342+
let virtual_os_global_root = StateRoots {
343+
contracts_trie_root_hash: initial_state_data.initial_state.contracts_trie_root_hash,
344+
classes_trie_root_hash: initial_state_data.initial_state.classes_trie_root_hash,
345+
}
346+
.global_root();
347+
let integration_test_global_root = integration_test_genesis_global_root();
348+
assert_eq!(
349+
virtual_os_global_root, integration_test_global_root,
350+
"The proof flow integration test uses a different global root than the virtual
351+
OS test. Please update the global root in the proof flow integration test to match the \
352+
virtual OS test and regenerate the proof fixtures (run `cargo +nightly-2025-07-14 test \
353+
-p starknet_os_flow_tests --features stwo_proving --release generate_proof_fixtures -- \
354+
--ignored`)."
355+
);
356+
}

0 commit comments

Comments
 (0)