diff --git a/unit_tests/src/constants.rs b/unit_tests/src/constants.rs index 9a65982..88177f5 100644 --- a/unit_tests/src/constants.rs +++ b/unit_tests/src/constants.rs @@ -142,8 +142,10 @@ pub const TRANSACTION_REVERTED: &str = pub const ACCOUNT_CONTRACT: &str = ""; pub const TEST_CONTRACT_ADDRESS: &str = ""; pub const CAIRO_1_ACCOUNT_CONTRACT_CLASS_HASH: &str = ""; -pub const TEST_CONTRACT_CLASS_HASH_V0: &str = "0x036e5b6081df2174189fb83800d2a09132286dcd1004ad960a0c8d69364e6e9a"; -pub const TEST_CONTRACT_CLASS_HASH_V1: &str = "0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"; +pub const TEST_CONTRACT_CLASS_HASH_V0: &str = + "0x036e5b6081df2174189fb83800d2a09132286dcd1004ad960a0c8d69364e6e9a"; +pub const TEST_CONTRACT_CLASS_HASH_V1: &str = + "0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"; /// /// Value to be used as a payload for a message in the `estimate_message_fee` test. @@ -161,7 +163,25 @@ pub const ARGENT_CONTRACT_ADDRESS: &str = ""; pub const ERR_DEOXYS: &str = "Error waiting for response from Deoxys client"; pub const ERR_PATHFINDER: &str = "Error waiting for response from Pathfinder client"; -pub const SPEC_0_5_1: &str = "0.5.1"; -pub const SPEC_0_6_0: &str = "0.6.0"; pub const SPEC_0_7_0: &str = "0.7.0"; pub const SPEC_0_7_1: &str = "0.7.1"; + +/// +/// Starknet block number versions. +/// +pub const BLOCK_0: u64 = 0; +pub const BLOCK_0_9_1: u64 = 3799; +pub const BLOCK_0_10_0: u64 = 4883; +pub const BLOCK_0_10_1: u64 = 6570; +pub const BLOCK_0_10_2: u64 = 12268; +pub const BLOCK_0_10_3: u64 = 16575; +pub const BLOCK_0_11_0: u64 = 28613; +pub const BLOCK_0_11_0_2: u64 = 43851; +pub const BLOCK_0_11_1: u64 = 61394; +pub const BLOCK_0_11_2: u64 = 68096; +pub const BLOCK_0_12_0: u64 = 103129; +pub const BLOCK_0_12_1: u64 = 164901; +pub const BLOCK_0_12_2: u64 = 194410; +pub const BLOCK_0_12_3: u64 = 472644; +pub const BLOCK_0_13_0: u64 = 501514; +pub const BLOCK_0_13_1: u64 = 607878; diff --git a/unit_tests/tests/test_get_class.rs b/unit_tests/tests/test_get_class.rs index 7fb4ec6..f3621dd 100644 --- a/unit_tests/tests/test_get_class.rs +++ b/unit_tests/tests/test_get_class.rs @@ -11,11 +11,13 @@ use std::collections::HashMap; #[rstest] #[tokio::test] -async fn fail_non_existing_block(clients: HashMap>) -> Result<()> { +async fn fail_non_existing_block( + clients: HashMap>, +) -> Result<()> { let deoxys = &clients[DEOXYS]; - let test_contract_class_hash = - FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0).map_err(|e| anyhow!("Invalid Contract Class Hash: {}", e))?; + let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0) + .map_err(|e| anyhow!("Invalid Contract Class Hash: {}", e))?; let block_id = BlockId::Number(800000); match deoxys.get_class(block_id, test_contract_class_hash).await { @@ -26,7 +28,7 @@ async fn fail_non_existing_block(clients: HashMap panic!("Unexpected success: Class was found when it shouldn't be."), } } @@ -69,8 +71,8 @@ async fn work_ok_retrieving_class_for_contract_version_0( let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; - let test_contract_class_hash = - FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0).expect("Invalid Contract Class Hash"); + let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0) + .expect("Invalid Contract Class Hash"); let deoxys_class = deoxys .get_class(BlockId::Number(50000), test_contract_class_hash) @@ -82,13 +84,20 @@ async fn work_ok_retrieving_class_for_contract_version_0( .await .unwrap(); - if let (ContractClass::Legacy(deoxys_legacy), ContractClass::Legacy(pathfinder_legacy)) = (deoxys_class, pathfinder_class) { - assert_eq!(deoxys_legacy.entry_points_by_type, pathfinder_legacy.entry_points_by_type); + if let (ContractClass::Legacy(deoxys_legacy), ContractClass::Legacy(pathfinder_legacy)) = + (deoxys_class, pathfinder_class) + { + assert_eq!( + deoxys_legacy.entry_points_by_type, + pathfinder_legacy.entry_points_by_type + ); assert_eq!(deoxys_legacy.abi, pathfinder_legacy.abi); - - let deoxys_program = decode(&deoxys_legacy.program).expect("Failed to decode base64 program"); - let pathfinder_program = decode(&pathfinder_legacy.program).expect("Failed to decode base64 program"); - + + let deoxys_program = + decode(&deoxys_legacy.program).expect("Failed to decode base64 program"); + let pathfinder_program = + decode(&pathfinder_legacy.program).expect("Failed to decode base64 program"); + assert_eq!(deoxys_program, pathfinder_program); } else { panic!("Contract classes are not of the Legacy variant"); diff --git a/unit_tests/tests/test_get_state_update.rs b/unit_tests/tests/test_get_state_update.rs index cd46deb..896af27 100644 --- a/unit_tests/tests/test_get_state_update.rs +++ b/unit_tests/tests/test_get_state_update.rs @@ -3,7 +3,9 @@ mod common; use common::*; -use starknet_core::types::{BlockId, BlockTag, MaybePendingStateUpdate, StarknetError, StateUpdate}; +use starknet_core::types::{ + BlockId, BlockTag, MaybePendingStateUpdate, StarknetError, StateUpdate, +}; use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; use std::collections::HashMap; @@ -27,7 +29,9 @@ pub fn sort_state_update(state_update: StateUpdate) -> StateUpdate { state_diff.deprecated_declared_classes.sort(); state_diff.declared_classes.sort_by_key(|x| x.class_hash); state_diff.deployed_contracts.sort_by_key(|x| x.address); - state_diff.replaced_classes.sort_by_key(|x| x.contract_address); + state_diff + .replaced_classes + .sort_by_key(|x| x.contract_address); state_diff.nonces.sort_by_key(|x| x.contract_address); sorted_state_update @@ -93,9 +97,18 @@ async fn work_genesis_block(clients: HashMap let sorted_pathfinder = extract_and_sort_state_update(response_pathfinder); let sorted_juno = extract_and_sort_state_update(response_juno); - assert_eq!(sorted_deoxys, sorted_pathfinder, "The sorted responses do not match"); - assert_eq!(sorted_deoxys, sorted_juno, "The sorted responses do not match"); - assert_eq!(sorted_juno, sorted_pathfinder, "The sorted responses do not match"); + assert_eq!( + sorted_deoxys, sorted_pathfinder, + "The sorted responses do not match" + ); + assert_eq!( + sorted_deoxys, sorted_juno, + "The sorted responses do not match" + ); + assert_eq!( + sorted_juno, sorted_pathfinder, + "The sorted responses do not match" + ); }