11use std:: env;
22
3+ use blockifier:: blockifier:: config:: ContractClassManagerConfig ;
4+ use blockifier:: state:: contract_class_manager:: ContractClassManager ;
35use blockifier_reexecution:: state_reader:: rpc_objects:: BlockId ;
46use blockifier_reexecution:: state_reader:: rpc_state_reader:: RpcStateReader ;
57use rstest:: fixture;
6- use starknet_api:: block:: BlockNumber ;
8+ use starknet_api:: block:: { BlockNumber , GasPrice } ;
79use starknet_api:: core:: ChainId ;
10+ use starknet_api:: execution_resources:: GasAmount ;
11+ use starknet_api:: transaction:: fields:: { AllResourceBounds , ResourceBounds , ValidResourceBounds } ;
812use starknet_types_core:: felt:: Felt ;
913use url:: Url ;
1014
11- use crate :: storage_proofs:: RpcStorageProofsProvider ;
15+ use crate :: runner:: { RpcRunnerFactory , RunnerConfig } ;
16+ use crate :: storage_proofs:: { RpcStorageProofsProvider , StorageProofConfig } ;
1217use crate :: virtual_block_executor:: RpcVirtualBlockExecutor ;
1318
19+ // ================================================================================================
20+ // Constants
21+ // ================================================================================================
22+
23+ // --- Mainnet ---
24+
1425/// Block number to use for testing (mainnet block with known state).
1526pub const TEST_BLOCK_NUMBER : u64 = 800000 ;
1627
@@ -22,12 +33,36 @@ pub const STRK_TOKEN_ADDRESS: Felt =
2233pub const SENDER_ADDRESS : Felt =
2334 Felt :: from_hex_unchecked ( "0x01176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8" ) ;
2435
25- /// Gets the RPC URL from the environment (NODE_URL).
36+ // --- Sepolia ---
37+
38+ /// STRK token contract address on Sepolia.
39+ pub const STRK_TOKEN_ADDRESS_SEPOLIA : Felt =
40+ Felt :: from_hex_unchecked ( "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d" ) ;
41+
42+ /// Dummy account on Sepolia (no signature validation required).
43+ /// This account uses the `account_with_dummy_validate` contract which always returns VALIDATED.
44+ pub const DUMMY_ACCOUNT_ADDRESS : Felt =
45+ Felt :: from_hex_unchecked ( "0x0786ed7d8dcbf1489241d65a4dd55f18b984c078558ce12def69802526fa918e" ) ;
46+
47+ // ================================================================================================
48+ // RPC URL Helpers
49+ // ================================================================================================
50+
51+ /// Gets the mainnet RPC URL from the environment (NODE_URL).
2652pub fn get_rpc_url ( ) -> String {
2753 env:: var ( "NODE_URL" ) . expect ( "NODE_URL environment variable required for this test" )
2854}
2955
30- /// Fixture that creates an RpcStateReader for testing.
56+ /// Gets the Sepolia RPC URL (defaults to local node, can be overridden via SEPOLIA_NODE_URL).
57+ pub fn get_sepolia_rpc_url ( ) -> String {
58+ env:: var ( "SEPOLIA_NODE_URL" ) . unwrap_or_else ( |_| "http://localhost:9546/rpc/v0_10" . to_string ( ) )
59+ }
60+
61+ // ================================================================================================
62+ // Mainnet Fixtures
63+ // ================================================================================================
64+
65+ /// Fixture that creates an RpcStateReader for mainnet testing.
3166#[ fixture]
3267pub fn rpc_state_reader ( ) -> RpcStateReader {
3368 let node_url = get_rpc_url ( ) ;
@@ -38,6 +73,7 @@ pub fn rpc_state_reader() -> RpcStateReader {
3873 )
3974}
4075
76+ /// Fixture that creates an RpcVirtualBlockExecutor for mainnet testing.
4177#[ fixture]
4278pub fn rpc_virtual_block_executor ( rpc_state_reader : RpcStateReader ) -> RpcVirtualBlockExecutor {
4379 RpcVirtualBlockExecutor {
@@ -47,10 +83,45 @@ pub fn rpc_virtual_block_executor(rpc_state_reader: RpcStateReader) -> RpcVirtua
4783 }
4884}
4985
50- /// Fixture that creates an RpcStorageProofsProvider for testing.
86+ /// Fixture that creates an RpcStorageProofsProvider for mainnet testing.
5187#[ fixture]
5288pub fn rpc_provider ( ) -> RpcStorageProofsProvider {
53- let rpc_url_str = get_rpc_url ( ) ;
54- let rpc_url = Url :: parse ( & rpc_url_str) . expect ( "Invalid RPC URL" ) ;
89+ let rpc_url = Url :: parse ( & get_rpc_url ( ) ) . expect ( "Invalid RPC URL" ) ;
5590 RpcStorageProofsProvider :: new ( rpc_url)
5691}
92+
93+ // ================================================================================================
94+ // Sepolia Fixtures
95+ // ================================================================================================
96+
97+ /// Fixture that creates an RpcRunnerFactory for Sepolia with committer enabled.
98+ ///
99+ /// This factory is configured to run the committer, meaning it will:
100+ /// - Build a FactsDb from RPC proofs and execution data.
101+ /// - Execute the committer to compute new state roots.
102+ /// - Generate commitment infos with actual root changes.
103+ #[ fixture]
104+ pub fn sepolia_runner_factory ( ) -> RpcRunnerFactory {
105+ let rpc_url = Url :: parse ( & get_sepolia_rpc_url ( ) ) . expect ( "Invalid Sepolia RPC URL" ) ;
106+ let contract_class_manager = ContractClassManager :: start ( ContractClassManagerConfig :: default ( ) ) ;
107+
108+ let runner_config =
109+ RunnerConfig { storage_proof_config : StorageProofConfig { include_state_changes : true } } ;
110+
111+ RpcRunnerFactory :: new ( rpc_url, ChainId :: Sepolia , contract_class_manager, runner_config)
112+ }
113+
114+ // ================================================================================================
115+ // Transaction Helpers
116+ // ================================================================================================
117+
118+ pub ( crate ) fn default_resource_bounds_for_client_side_tx ( ) -> ValidResourceBounds {
119+ ValidResourceBounds :: AllResources ( AllResourceBounds {
120+ l1_gas : ResourceBounds { max_amount : GasAmount ( 0 ) , max_price_per_unit : GasPrice ( 0 ) } ,
121+ l2_gas : ResourceBounds {
122+ max_amount : GasAmount ( 10_000_000 ) ,
123+ max_price_per_unit : GasPrice ( 0 ) ,
124+ } ,
125+ l1_data_gas : ResourceBounds { max_amount : GasAmount ( 0 ) , max_price_per_unit : GasPrice ( 0 ) } ,
126+ } )
127+ }
0 commit comments