@@ -28,7 +28,7 @@ use starknet_in_rust::{
28
28
state_cache:: StorageEntry ,
29
29
BlockInfo ,
30
30
} ,
31
- transaction:: { InvokeFunction , Transaction } ,
31
+ transaction:: InvokeFunction ,
32
32
utils:: { Address , ClassHash } ,
33
33
} ;
34
34
@@ -87,10 +87,12 @@ impl StateReader for RpcStateReader {
87
87
}
88
88
89
89
#[ allow( unused) ]
90
- pub fn execute_tx (
90
+ pub fn execute_tx_configurable (
91
91
tx_hash : & str ,
92
92
network : RpcChain ,
93
93
block_number : BlockNumber ,
94
+ skip_validate : bool ,
95
+ skip_nonce_check : bool ,
94
96
) -> (
95
97
TransactionExecutionInfo ,
96
98
TransactionTrace ,
@@ -138,9 +140,9 @@ pub fn execute_tx(
138
140
// Get transaction before giving ownership of the reader
139
141
let tx_hash = TransactionHash ( stark_felt ! ( tx_hash) ) ;
140
142
let tx = match rpc_reader. 0 . get_transaction ( & tx_hash) {
141
- SNTransaction :: Invoke ( tx) => Transaction :: InvokeFunction (
142
- InvokeFunction :: from_invoke_transaction ( tx , chain_id ) . unwrap ( ) ,
143
- ) ,
143
+ SNTransaction :: Invoke ( tx) => InvokeFunction :: from_invoke_transaction ( tx , chain_id )
144
+ . unwrap ( )
145
+ . create_for_simulation ( skip_validate , false , false , false , skip_nonce_check ) ,
144
146
_ => unimplemented ! ( ) ,
145
147
} ;
146
148
@@ -169,6 +171,30 @@ pub fn execute_tx(
169
171
)
170
172
}
171
173
174
+ pub fn execute_tx (
175
+ tx_hash : & str ,
176
+ network : RpcChain ,
177
+ block_number : BlockNumber ,
178
+ ) -> (
179
+ TransactionExecutionInfo ,
180
+ TransactionTrace ,
181
+ RpcTransactionReceipt ,
182
+ ) {
183
+ execute_tx_configurable ( tx_hash, network, block_number, false , false )
184
+ }
185
+
186
+ pub fn execute_tx_without_validate (
187
+ tx_hash : & str ,
188
+ network : RpcChain ,
189
+ block_number : BlockNumber ,
190
+ ) -> (
191
+ TransactionExecutionInfo ,
192
+ TransactionTrace ,
193
+ RpcTransactionReceipt ,
194
+ ) {
195
+ execute_tx_configurable ( tx_hash, network, block_number, true , true )
196
+ }
197
+
172
198
#[ test]
173
199
fn test_get_transaction_try_from ( ) {
174
200
let rpc_state = RpcState :: new_infura ( RpcChain :: MainNet , BlockTag :: Latest . into ( ) ) ;
@@ -359,3 +385,17 @@ fn starknet_in_rust_test_case_reverted_tx(hash: &str, block_number: u64, chain:
359
385
) ;
360
386
}
361
387
}
388
+
389
+ #[ test_case(
390
+ "0x038c307a0a324dc92778820f2c6317f40157c06b12a7e537f7a16b2c015f64e7" ,
391
+ 274333 -1 ,
392
+ RpcChain :: MainNet
393
+ ) ]
394
+ fn test_validate_fee ( hash : & str , block_number : u64 , chain : RpcChain ) {
395
+ let ( tx_info, _trace, receipt) = execute_tx ( hash, chain, BlockNumber ( block_number) ) ;
396
+ let ( tx_info_without_fee, _trace, _receipt) =
397
+ execute_tx_without_validate ( hash, chain, BlockNumber ( block_number) ) ;
398
+
399
+ assert_eq ! ( tx_info. actual_fee, receipt. actual_fee) ;
400
+ assert ! ( tx_info_without_fee. actual_fee < tx_info. actual_fee) ;
401
+ }
0 commit comments