|
1 | 1 | use std::sync::Arc;
|
2 | 2 |
|
3 | 3 | use cairo_vm::felt::{felt_str, Felt252};
|
| 4 | +use cairo_vm::vm::runners::cairo_runner::ExecutionResources; |
4 | 5 | use pretty_assertions_sorted::{assert_eq, assert_eq_sorted};
|
| 6 | +use rpc_state_reader::utils::rpc_call_info_to_call_info; |
5 | 7 | use starknet_api::{
|
6 | 8 | block::BlockNumber,
|
7 | 9 | core::{ClassHash as SNClassHash, ContractAddress, PatriciaKey},
|
@@ -34,7 +36,7 @@ use starknet_in_rust::{
|
34 | 36 |
|
35 | 37 | use test_case::test_case;
|
36 | 38 |
|
37 |
| -use rpc_state_reader::rpc_state::*; |
| 39 | +use rpc_state_reader::{rpc_state::*, utils::starkfelt_to_felt252}; |
38 | 40 |
|
39 | 41 | pub struct RpcStateReader(RpcState);
|
40 | 42 |
|
@@ -195,6 +197,21 @@ fn test_get_gas_price() {
|
195 | 197 | assert_eq!(price, 22804578690);
|
196 | 198 | }
|
197 | 199 |
|
| 200 | +/// Removes data from the call info that the RpcCallInfo struct doesn't have, so we can compare them properly |
| 201 | +fn strip_call_info_to_compare(call_info: &CallInfo) -> CallInfo { |
| 202 | + CallInfo { |
| 203 | + calldata: call_info.calldata.clone(), |
| 204 | + execution_resources: call_info.execution_resources.clone(), |
| 205 | + retdata: call_info.retdata.clone(), |
| 206 | + internal_calls: call_info |
| 207 | + .internal_calls |
| 208 | + .iter() |
| 209 | + .map(strip_call_info_to_compare) |
| 210 | + .collect(), |
| 211 | + ..Default::default() |
| 212 | + } |
| 213 | +} |
| 214 | + |
198 | 215 | #[test_case(
|
199 | 216 | "0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5",
|
200 | 217 | 90006,
|
@@ -283,6 +300,18 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain)
|
283 | 300 | "internal calls length mismatch"
|
284 | 301 | );
|
285 | 302 |
|
| 303 | + let rpc_internal_calls = &trace.function_invocation.as_ref().unwrap().internal_calls; |
| 304 | + let rpc_internal_calls: Vec<CallInfo> = rpc_internal_calls |
| 305 | + .iter() |
| 306 | + .map(rpc_call_info_to_call_info) |
| 307 | + .collect(); |
| 308 | + |
| 309 | + let stripped_internal_calls: Vec<CallInfo> = internal_calls |
| 310 | + .iter() |
| 311 | + .map(strip_call_info_to_compare) |
| 312 | + .collect(); |
| 313 | + assert_eq_sorted!(stripped_internal_calls, rpc_internal_calls); |
| 314 | + |
286 | 315 | // check actual fee calculation
|
287 | 316 | if receipt.actual_fee != actual_fee {
|
288 | 317 | let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee;
|
|
0 commit comments