@@ -11,6 +11,7 @@ use mempool_test_utils::starknet_api_test_utils::{
1111} ;
1212use mockall:: predicate:: eq;
1313use rstest:: rstest;
14+ use starknet_api:: consensus_transaction:: ConsensusTransaction ;
1415use starknet_api:: executable_transaction:: ValidateCompiledClassHashError ;
1516use starknet_api:: rpc_transaction:: { RpcDeclareTransaction , RpcTransaction } ;
1617use starknet_api:: transaction:: fields:: Proof ;
@@ -66,7 +67,7 @@ async fn test_compiled_class_hash_mismatch() {
6667#[ rstest]
6768#[ tokio:: test]
6869async fn test_proof_verification_called_for_invoke_v3_with_proof_facts ( ) {
69- // Create an invoke transaction with proof_facts and proof.
70+ // Create an invoke transaction with proof facts and proof.
7071 let proof_facts = proof_facts ! [ felt!( "0x1" ) , felt!( "0x2" ) , felt!( "0x3" ) ] ;
7172 let proof = Proof :: from ( vec ! [ 1u32 , 2u32 , 3u32 ] ) ;
7273 let invoke_tx = invoke_tx_client_side_proving (
@@ -76,16 +77,12 @@ async fn test_proof_verification_called_for_invoke_v3_with_proof_facts() {
7677 ) ;
7778
7879 let mut mock_proof_manager_client = MockProofManagerClient :: new ( ) ;
80+ // Expect contains proof to be called and return false (proof does not exist).
7981 mock_proof_manager_client
8082 . expect_contains_proof ( )
8183 . once ( )
8284 . with ( eq ( proof_facts. clone ( ) ) )
8385 . return_once ( |_| Ok ( false ) ) ;
84- mock_proof_manager_client
85- . expect_set_proof ( )
86- . once ( )
87- . with ( eq ( proof_facts) , eq ( proof) )
88- . return_once ( |_, _| Ok ( ( ) ) ) ;
8986
9087 let mock_class_manager_client = MockClassManagerClient :: new ( ) ;
9188
@@ -105,7 +102,7 @@ async fn test_proof_verification_skipped_for_invoke_v3_without_proof_facts() {
105102 // Create an invoke transaction without proof_facts.
106103 let invoke_tx = invoke_tx ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
107104
108- // Mock proof manager client expects NO calls to contains_proof or set_proof .
105+ // Mock proof manager client expects NO calls to contains proof or set proof .
109106 let mock_proof_manager_client = MockProofManagerClient :: new ( ) ;
110107 let mock_class_manager_client = MockClassManagerClient :: new ( ) ;
111108
@@ -116,14 +113,13 @@ async fn test_proof_verification_skipped_for_invoke_v3_without_proof_facts() {
116113 ) ;
117114
118115 // Convert the RPC transaction to an internal RPC transaction.
119- // This should succeed without calling contains_proof or set_proof .
116+ // This should succeed without calling contains proof or set proof .
120117 transaction_converter. convert_rpc_tx_to_internal_rpc_tx ( invoke_tx) . await . unwrap ( ) ;
121118}
122119
123120#[ rstest]
124121#[ tokio:: test]
125- async fn test_proof_verification_skipped_when_proof_already_exists ( ) {
126- // Create an invoke transaction with proof_facts and proof.
122+ async fn test_consensus_tx_to_internal_with_proof_facts_verifies_and_sets_proof ( ) {
127123 let proof_facts = proof_facts ! [ felt!( "0x1" ) , felt!( "0x2" ) , felt!( "0x3" ) ] ;
128124 let proof = Proof :: from ( vec ! [ 1u32 , 2u32 , 3u32 ] ) ;
129125 let invoke_tx = invoke_tx_client_side_proving (
@@ -132,14 +128,24 @@ async fn test_proof_verification_skipped_when_proof_already_exists() {
132128 proof. clone ( ) ,
133129 ) ;
134130
131+ let consensus_tx = ConsensusTransaction :: RpcTransaction ( invoke_tx) ;
132+
135133 let mut mock_proof_manager_client = MockProofManagerClient :: new ( ) ;
136- // Expect contains_proof to be called and return true (proof already exists).
134+
135+ // Expect contains proof to be called during conversion from rpc to internal rpc.
137136 mock_proof_manager_client
138137 . expect_contains_proof ( )
139138 . once ( )
140- . with ( eq ( proof_facts) )
141- . return_once ( |_| Ok ( true ) ) ;
142- // Since proof already exists, expect set_proof to NOT be called.
139+ . with ( eq ( proof_facts. clone ( ) ) )
140+ . return_once ( |_| Ok ( false ) ) ;
141+
142+ // Expect set proof to be called after the conversion succeeds.
143+ // This is specific to conversion from consensus to internal consensus.
144+ mock_proof_manager_client
145+ . expect_set_proof ( )
146+ . once ( )
147+ . with ( eq ( proof_facts) , eq ( proof) )
148+ . return_once ( |_, _| Ok ( ( ) ) ) ;
143149
144150 let mock_class_manager_client = MockClassManagerClient :: new ( ) ;
145151
@@ -149,7 +155,10 @@ async fn test_proof_verification_skipped_when_proof_already_exists() {
149155 ChainInfo :: create_for_testing ( ) . chain_id ,
150156 ) ;
151157
152- // Convert the RPC transaction to an internal RPC transaction.
153- // This should succeed and only call contains_proof, not set_proof.
154- transaction_converter. convert_rpc_tx_to_internal_rpc_tx ( invoke_tx) . await . unwrap ( ) ;
158+ // Convert the consensus transaction to an internal consensus transaction.
159+ // This should call contains proof and set proof.
160+ transaction_converter
161+ . convert_consensus_tx_to_internal_consensus_tx ( consensus_tx)
162+ . await
163+ . unwrap ( ) ;
155164}
0 commit comments