From 74e51d1e2db74eb3443e8c1a8e9f3360136b4a0a Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 17 Jun 2024 17:18:23 +0200 Subject: [PATCH 1/4] refacto consts --- README.md | 4 +- rustc-ice-2024-06-17T15_15_44-57848.txt | 89 +++++++++++++++++++ unit_tests/src/constants/mainnet/block.rs | 19 ++++ unit_tests/src/constants/mainnet/contract.rs | 54 +++++++++++ unit_tests/src/constants/mainnet/mod.rs | 4 + unit_tests/src/constants/mainnet/network.rs | 3 + .../src/constants/mainnet/transaction.rs | 0 unit_tests/src/constants/mod.rs | 2 + unit_tests/src/constants/sepolia/block.rs | 19 ++++ .../src/{ => constants/sepolia}/constants.rs | 19 ---- unit_tests/src/constants/sepolia/contract.rs | 0 unit_tests/src/constants/sepolia/mod.rs | 4 + unit_tests/src/constants/sepolia/network.rs | 0 .../src/constants/sepolia/transaction.rs | 0 unit_tests/src/fixtures.rs | 6 +- unit_tests/src/lib.rs | 10 +-- .../tests/test_block_hash_and_number.rs | 6 +- unit_tests/tests/test_block_number.rs | 6 +- unit_tests/tests/test_call.rs | 30 +++---- unit_tests/tests/test_chain_id.rs | 4 +- unit_tests/tests/test_estimate_fee.rs | 8 +- .../tests/test_get_block_transaction_count.rs | 20 ++--- .../tests/test_get_block_with_tx_hashes.rs | 10 +-- unit_tests/tests/test_get_block_with_txs.rs | 14 +-- unit_tests/tests/test_get_class.rs | 12 +-- unit_tests/tests/test_get_class_at.rs | 8 +- unit_tests/tests/test_get_class_hash_at.rs | 12 +-- unit_tests/tests/test_get_nonce.rs | 16 ++-- unit_tests/tests/test_get_state_update.rs | 32 +++---- unit_tests/tests/test_get_storage_at.rs | 10 +-- ...t_get_transaction_by_block_id_and_index.rs | 20 ++--- .../tests/test_get_transaction_by_hash.rs | 18 ++-- .../tests/test_get_transaction_receipt.rs | 2 +- .../tests/test_get_transaction_status.rs | 14 +-- unit_tests/tests/test_spec_version.rs | 6 +- unit_tests/tests/test_syncing.rs | 6 +- 36 files changed, 331 insertions(+), 156 deletions(-) create mode 100644 rustc-ice-2024-06-17T15_15_44-57848.txt create mode 100644 unit_tests/src/constants/mainnet/block.rs create mode 100644 unit_tests/src/constants/mainnet/contract.rs create mode 100644 unit_tests/src/constants/mainnet/mod.rs create mode 100644 unit_tests/src/constants/mainnet/network.rs create mode 100644 unit_tests/src/constants/mainnet/transaction.rs create mode 100644 unit_tests/src/constants/mod.rs create mode 100644 unit_tests/src/constants/sepolia/block.rs rename unit_tests/src/{ => constants/sepolia}/constants.rs (91%) create mode 100644 unit_tests/src/constants/sepolia/contract.rs create mode 100644 unit_tests/src/constants/sepolia/mod.rs create mode 100644 unit_tests/src/constants/sepolia/network.rs create mode 100644 unit_tests/src/constants/sepolia/transaction.rs diff --git a/README.md b/README.md index d127a16..d179684 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,8 @@ use starknet_providers::{jsonrpc::{HttpTransport, JsonRpcClient}, Provider}; #[rstest] #[tokio::test] async fn work_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys.block_number().await.expect("Deoxys : Error while getting the block number"); let response_pathfinder = pathfinder.block_number().await.expect("RPC : Error while getting the block number"); diff --git a/rustc-ice-2024-06-17T15_15_44-57848.txt b/rustc-ice-2024-06-17T15_15_44-57848.txt new file mode 100644 index 0000000..32791e8 --- /dev/null +++ b/rustc-ice-2024-06-17T15_15_44-57848.txt @@ -0,0 +1,89 @@ +thread 'rustc' panicked at compiler/rustc_hir_typeck/src/coercion.rs:461:35: +coerce_borrowed_pointer had no error +stack backtrace: + 0: 0x1058bc40c - std::backtrace::Backtrace::create::hab373be4a39910fb + 1: 0x10eebb4c0 - std[e77b8cc82bfbcdfd]::panicking::update_hook::>::{closure#0} + 2: 0x1058d4f74 - std::panicking::rust_panic_with_hook::hc40baab8129fe7f9 + 3: 0x1058d4d30 - std::panicking::begin_panic_handler::{{closure}}::h8ee754464294b312 + 4: 0x1058d2448 - std::sys_common::backtrace::__rust_end_short_backtrace::h27c89c5d3d647845 + 5: 0x1058d4ab8 - _rust_begin_unwind + 6: 0x10592f968 - core::panicking::panic_fmt::h9a57bdc8b84feb8a + 7: 0x105912254 - core::panicking::panic_display::h8c3e604e2155e141 + 8: 0x10592f934 - core::option::expect_failed::he6ed1e5d6f9a63e8 + 9: 0x10f39c004 - ::coerce + 10: 0x10f40ad40 - ::commit_if_ok::, rustc_middle[82fdd60edd279704]::ty::Ty)>, rustc_middle[82fdd60edd279704]::ty::error::TypeError, ::try_find_coercion_lub<&rustc_hir[b8623ccb6b2d4e43]::hir::Expr>::{closure#4}> + 11: 0x10f278178 - ::coerce + 12: 0x10f29ab4c - ::check_argument_types + 13: 0x10f274b1c - ::confirm_builtin_call + 14: 0x10f273804 - ::check_call + 15: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 16: 0x10f2a0ec4 - ::check_stmt + 17: 0x10f2a13bc - ::check_block_with_expected + 18: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 19: 0x10f2dabec - ::check_match + 20: 0x10f2df124 - ::check_expr_kind + 21: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 22: 0x10f2a0ec4 - ::check_stmt + 23: 0x10f2a13bc - ::check_block_with_expected + 24: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 25: 0x10f2a13f0 - ::check_block_with_expected + 26: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 27: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 28: 0x10f2a13f0 - ::check_block_with_expected + 29: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 30: 0x10f284768 - ::check_return_expr + 31: 0x10f35a874 - rustc_hir_typeck[46c6058f98d0f6e4]::check::check_fn + 32: 0x10f2dca88 - ::check_expr_closure + 33: 0x10f2835f4 - ::check_expr_with_expectation_and_args + 34: 0x10f284768 - ::check_return_expr + 35: 0x10f35a874 - rustc_hir_typeck[46c6058f98d0f6e4]::check::check_fn + 36: 0x10f3e9bf0 - rustc_hir_typeck[46c6058f98d0f6e4]::typeck + 37: 0x1100fa7d0 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::> + 38: 0x110251c3c - >::call_once + 39: 0x1100b2b64 - rustc_query_system[f11765a6e63743ab]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt, true> + 40: 0x110006260 - rustc_query_system[f11765a6e63743ab]::query::plumbing::force_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt> + 41: 0x1100dbb20 - ::{closure#0} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<(rustc_middle[82fdd60edd279704]::ty::context::TyCtxt, rustc_query_system[f11765a6e63743ab]::dep_graph::dep_node::DepNode)>>::call_once + 42: 0x1101ef020 - >::try_mark_previous_green:: + 43: 0x1101ef068 - >::try_mark_previous_green:: + 44: 0x1101eeddc - >::try_mark_green:: + 45: 0x11001f79c - rustc_query_system[f11765a6e63743ab]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt, true> + 46: 0x11016f404 - rustc_query_impl[d9b7452daba4f436]::query_impl::type_of::get_query_incr::__rust_end_short_backtrace + 47: 0x10f0f7a70 - rustc_middle[82fdd60edd279704]::query::plumbing::query_get_at::>> + 48: 0x10f101298 - rustc_hir_analysis[7f32bdd8a1d62b1c]::check::check::check_item_type + 49: 0x10f201470 - rustc_hir_analysis[7f32bdd8a1d62b1c]::check::wfcheck::check_well_formed + 50: 0x1100f6d90 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::> + 51: 0x1101993b8 - >::call_once + 52: 0x1100bed78 - rustc_query_system[f11765a6e63743ab]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt, true> + 53: 0x110006d58 - rustc_query_system[f11765a6e63743ab]::query::plumbing::force_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt> + 54: 0x1100cf9e0 - ::{closure#0} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<(rustc_middle[82fdd60edd279704]::ty::context::TyCtxt, rustc_query_system[f11765a6e63743ab]::dep_graph::dep_node::DepNode)>>::call_once + 55: 0x1101ef020 - >::try_mark_previous_green:: + 56: 0x1101eeddc - >::try_mark_green:: + 57: 0x11000906c - rustc_query_system[f11765a6e63743ab]::query::plumbing::ensure_must_run::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt> + 58: 0x1101b9858 - rustc_query_impl[d9b7452daba4f436]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace + 59: 0x10f0f8050 - rustc_middle[82fdd60edd279704]::query::plumbing::query_ensure_error_guaranteed::>, ()> + 60: 0x10f0d6740 - ::run::, rustc_data_structures[712596e8823b4fc6]::sync::parallel::enabled::try_par_for_each_in<&[rustc_hir[b8623ccb6b2d4e43]::hir_id::OwnerId], rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed, ::try_par_for_each_module::{closure#0}>::{closure#0}::{closure#2}::{closure#0}> + 61: 0x10f19a57c - rustc_hir_analysis[7f32bdd8a1d62b1c]::check_crate + 62: 0x10f6529fc - rustc_interface[9b9c728c161af33d]::passes::analysis + 63: 0x1100fa870 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::> + 64: 0x1101e82cc - >::call_once + 65: 0x110029308 - rustc_query_system[f11765a6e63743ab]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt, true> + 66: 0x1101b87fc - rustc_query_impl[d9b7452daba4f436]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace + 67: 0x10eec4ee4 - ::enter::> + 68: 0x10ee8f3f4 - ::enter::, rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>> + 69: 0x10eec2c38 - rustc_span[9910a9a9a2b8b1b0]::set_source_map::, rustc_interface[9b9c728c161af33d]::interface::run_compiler, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}::{closure#0}> + 70: 0x10eec4100 - rustc_span[9910a9a9a2b8b1b0]::create_session_globals_then::, rustc_interface[9b9c728c161af33d]::util::run_in_thread_pool_with_globals, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}> + 71: 0x10eeb8aa0 - std[e77b8cc82bfbcdfd]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>> + 72: 0x10ee88cf4 - <::spawn_unchecked_, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#1} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 73: 0x1058dc788 - std::sys::pal::unix::thread::Thread::new::thread_start::ha368f5c01e431785 + 74: 0x185dd7034 - __pthread_joiner_wake + + +rustc version: 1.78.0-nightly (1a648b397 2024-02-11) +platform: aarch64-apple-darwin + +query stack during panic: +#0 [typeck] type-checking `work_transaction_invoke::{closure#0}::work_transaction_invoke` +#1 [type_of] computing type of `work_transaction_invoke::{closure#0}::work_transaction_invoke::{opaque#0}` +#2 [check_well_formed] checking that `work_transaction_invoke::{closure#0}::work_transaction_invoke::{opaque#0}` is well-formed +#3 [analysis] running analysis passes on this crate +end of query stack diff --git a/unit_tests/src/constants/mainnet/block.rs b/unit_tests/src/constants/mainnet/block.rs new file mode 100644 index 0000000..e7ee223 --- /dev/null +++ b/unit_tests/src/constants/mainnet/block.rs @@ -0,0 +1,19 @@ +/// +/// Starknet Mainnet 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/src/constants/mainnet/contract.rs b/unit_tests/src/constants/mainnet/contract.rs new file mode 100644 index 0000000..7ed6a84 --- /dev/null +++ b/unit_tests/src/constants/mainnet/contract.rs @@ -0,0 +1,54 @@ +/// +/// Contract address for StarkGate ETH starknet bridge. +/// +/// Details concerning available methods can be found on [StarkScan](https://starkscan.co/contract/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7#read-write-contract) +/// +pub const STARKGATE_ETH_BRIDGE_ADDR: &str = + "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; + +/// +/// Contract address for Jediswap exchange. +/// +/// Details concerning available methods can be found on [StarkScan](https://starkscan.co/contract/0x041fd22b238fa21cfcf5dd45a8548974d8263b3a531a60388411c5e230f97023#read-write-contract): +/// +pub const JEDI_SWAP_ADDR: &str = + "0x041fd22b238fa21cfcf5dd45a8548974d8263b3a531a60388411c5e230f97023"; + +/// +/// Contract address for Starkgate USDC on Starknet. +/// +/// Details concerning this coin can be found on [StarkScan](https://starkscan.co/token/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8): +/// +pub const STARKGATE_USDC: &str = + "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"; + +/// +/// Contract address fpr Starkgate Ether on Starknet. +/// +/// Detail concerning this coin can be found on [StarkScan](https://starkscan.co/token/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7): +/// +pub const STARKGATE_ETHER: &str = + "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; + +/// +/// Random ERC721 Starknet contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x07fa9a8eacb89fb6cd0c7fe557e71c42a4b181ba328a9a04958136e6469c4e00) +/// +pub const CONTRACT_ERC721: &str = + "0x07fa9a8eacb89fb6cd0c7fe557e71c42a4b181ba328a9a04958136e6469c4e00"; + +/// +/// Random ERC20 Starknet contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x04a5fdce70877b77f03aea8a29259176f88d5bea9d0ad8c0118f5316425e6ba0) +/// +pub const CONTRACT_ERC20: &str = + "0x04a5fdce70877b77f03aea8a29259176f88d5bea9d0ad8c0118f5316425e6ba0"; + +/// +/// Random ACCOUNT Starknet contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32) +pub const CONTRACT_ACCOUNT: &str = + "0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32"; \ No newline at end of file diff --git a/unit_tests/src/constants/mainnet/mod.rs b/unit_tests/src/constants/mainnet/mod.rs new file mode 100644 index 0000000..eb58750 --- /dev/null +++ b/unit_tests/src/constants/mainnet/mod.rs @@ -0,0 +1,4 @@ +pub mod block; +pub mod transaction; +pub mod network; +pub mod contract; \ No newline at end of file diff --git a/unit_tests/src/constants/mainnet/network.rs b/unit_tests/src/constants/mainnet/network.rs new file mode 100644 index 0000000..0351fed --- /dev/null +++ b/unit_tests/src/constants/mainnet/network.rs @@ -0,0 +1,3 @@ +pub const DEOXYS: &str = "deoxys"; +pub const PATHFINDER: &str = "pathfinder"; +pub const JUNO: &str = "juno"; \ No newline at end of file diff --git a/unit_tests/src/constants/mainnet/transaction.rs b/unit_tests/src/constants/mainnet/transaction.rs new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/src/constants/mod.rs b/unit_tests/src/constants/mod.rs new file mode 100644 index 0000000..8a17b48 --- /dev/null +++ b/unit_tests/src/constants/mod.rs @@ -0,0 +1,2 @@ +pub mod mainnet; +pub mod sepolia; \ No newline at end of file diff --git a/unit_tests/src/constants/sepolia/block.rs b/unit_tests/src/constants/sepolia/block.rs new file mode 100644 index 0000000..e7ee223 --- /dev/null +++ b/unit_tests/src/constants/sepolia/block.rs @@ -0,0 +1,19 @@ +/// +/// Starknet Mainnet 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/src/constants.rs b/unit_tests/src/constants/sepolia/constants.rs similarity index 91% rename from unit_tests/src/constants.rs rename to unit_tests/src/constants/sepolia/constants.rs index 3cdedcc..383650a 100644 --- a/unit_tests/src/constants.rs +++ b/unit_tests/src/constants/sepolia/constants.rs @@ -166,22 +166,3 @@ pub const ERR_PATHFINDER: &str = "Error waiting for response from Pathfinder cli 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/src/constants/sepolia/contract.rs b/unit_tests/src/constants/sepolia/contract.rs new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/src/constants/sepolia/mod.rs b/unit_tests/src/constants/sepolia/mod.rs new file mode 100644 index 0000000..eb58750 --- /dev/null +++ b/unit_tests/src/constants/sepolia/mod.rs @@ -0,0 +1,4 @@ +pub mod block; +pub mod transaction; +pub mod network; +pub mod contract; \ No newline at end of file diff --git a/unit_tests/src/constants/sepolia/network.rs b/unit_tests/src/constants/sepolia/network.rs new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/src/constants/sepolia/transaction.rs b/unit_tests/src/constants/sepolia/transaction.rs new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/src/fixtures.rs b/unit_tests/src/fixtures.rs index da8430c..c2324ee 100644 --- a/unit_tests/src/fixtures.rs +++ b/unit_tests/src/fixtures.rs @@ -41,8 +41,8 @@ pub fn clients( juno: JsonRpcClient, ) -> HashMap> { map! { - String::from(DEOXYS) => deoxys, - String::from(PATHFINDER) => pathfinder, - String::from(JUNO) => juno, + String::from(mainnet::network::DEOXYS) => deoxys, + String::from(mainnet::network::PATHFINDER) => pathfinder, + String::from(mainnet::network::JUNO) => juno, } } diff --git a/unit_tests/src/lib.rs b/unit_tests/src/lib.rs index 6e2aae0..da0b1db 100644 --- a/unit_tests/src/lib.rs +++ b/unit_tests/src/lib.rs @@ -1,6 +1,5 @@ #![feature(assert_matches)] -use constants::*; use starknet_accounts::{Account, Call, ConnectedAccount, Execution, SingleOwnerAccount}; use starknet_core::chain_id; use starknet_core::types::BroadcastedInvokeTransaction; @@ -10,6 +9,7 @@ use starknet_core::{ }; use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient}; use starknet_signers::{LocalWallet, SigningKey}; +use constants::mainnet; pub mod constants; pub mod fixtures; @@ -28,10 +28,10 @@ impl TransactionFactory for OkTransactionFactory { max_fee: FieldElement::ZERO, signature: vec![], nonce: nonce.unwrap_or(FieldElement::ZERO), - sender_address: FieldElement::from_hex_be(ACCOUNT_CONTRACT).unwrap(), + sender_address: FieldElement::from_hex_be(mainnet::contract::CONTRACT_ACCOUNT).unwrap(), calldata: vec![ - FieldElement::from_hex_be(TEST_CONTRACT_ADDRESS).unwrap(), - get_selector_from_name("sqrt").unwrap(), + FieldElement::from_hex_be(mainnet::contract::CONTRACT_ERC20).unwrap(), + get_selector_from_name("transfer").unwrap(), FieldElement::from_hex_be("1").unwrap(), FieldElement::from(81u8), ], @@ -70,7 +70,7 @@ impl TransactionFactory for MaxFeeTransactionFactory { ) .unwrap(), calldata: vec![ - FieldElement::from_hex_be(TEST_CONTRACT_ADDRESS).unwrap(), + FieldElement::from_hex_be(mainnet::contract::CONTRACT_ERC20).unwrap(), get_selector_from_name("sqrt").unwrap(), FieldElement::from_hex_be("1").unwrap(), FieldElement::from(81u8), diff --git a/unit_tests/tests/test_block_hash_and_number.rs b/unit_tests/tests/test_block_hash_and_number.rs index 591634d..33f619d 100644 --- a/unit_tests/tests/test_block_hash_and_number.rs +++ b/unit_tests/tests/test_block_hash_and_number.rs @@ -20,9 +20,9 @@ use colored::*; #[rstest] #[tokio::test] async fn work_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let deoxys_responce = deoxys .block_hash_and_number() diff --git a/unit_tests/tests/test_block_number.rs b/unit_tests/tests/test_block_number.rs index 92f671b..d32ddf7 100644 --- a/unit_tests/tests/test_block_number.rs +++ b/unit_tests/tests/test_block_number.rs @@ -18,9 +18,9 @@ use starknet_providers::{ #[rstest] #[tokio::test] async fn work_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let response_deoxys = deoxys .block_number() diff --git a/unit_tests/tests/test_call.rs b/unit_tests/tests/test_call.rs index 08f6048..0d63949 100644 --- a/unit_tests/tests/test_call.rs +++ b/unit_tests/tests/test_call.rs @@ -23,8 +23,8 @@ use starknet_providers::{ #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .call( @@ -74,8 +74,8 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .call( @@ -128,7 +128,7 @@ async fn fail_non_existing_contract(clients: HashMap>, ) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .call( @@ -164,8 +164,8 @@ async fn fail_invalid_contract_entry_point_selector( #[rstest] #[tokio::test] async fn fail_missing_contract_call_data(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .call( @@ -220,7 +220,7 @@ async fn fail_missing_contract_call_data(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .call( @@ -249,7 +249,7 @@ async fn fail_invalid_contract_call_data(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .call( @@ -292,8 +292,8 @@ async fn fail_too_many_call_data(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .call( @@ -334,8 +334,8 @@ async fn work_correct_call(clients: HashMap #[rstest] #[tokio::test] async fn work_correct_call_with_args(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_number = get_block_setting(); @@ -378,8 +378,8 @@ async fn work_correct_call_with_args(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_number = get_block_setting(); diff --git a/unit_tests/tests/test_chain_id.rs b/unit_tests/tests/test_chain_id.rs index 0b08094..ef11e9a 100644 --- a/unit_tests/tests/test_chain_id.rs +++ b/unit_tests/tests/test_chain_id.rs @@ -13,8 +13,8 @@ use std::collections::HashMap; #[rstest] #[tokio::test] async fn chain_id(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .chain_id() diff --git a/unit_tests/tests/test_estimate_fee.rs b/unit_tests/tests/test_estimate_fee.rs index ccfc8aa..57bf305 100644 --- a/unit_tests/tests/test_estimate_fee.rs +++ b/unit_tests/tests/test_estimate_fee.rs @@ -18,7 +18,7 @@ use unit_tests::{BadTransactionFactory, OkTransactionFactory, TransactionFactory #[tokio::test] #[ignore = "Fix failing unwrap due to empty constant"] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let ok_invoke_transaction = OkTransactionFactory::build(Some(FieldElement::ZERO)); let simulation_flag = vec![SimulationFlagForEstimateFee::SkipValidate]; @@ -52,7 +52,7 @@ async fn fail_non_existing_block(clients: HashMap>, ) { - let deoxys = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::PATHFINDER]; let bad_invoke_transaction = BadTransactionFactory::build(None); let simulate_flag = vec![SimulationFlagForEstimateFee::SkipValidate]; @@ -82,8 +82,8 @@ async fn fail_if_one_txn_cannot_be_executed( #[tokio::test] #[ignore = "Fix failing unwrap due to empty constant"] async fn works_ok(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_number = get_block_setting(); diff --git a/unit_tests/tests/test_get_block_transaction_count.rs b/unit_tests/tests/test_get_block_transaction_count.rs index a43d3d9..de276f8 100644 --- a/unit_tests/tests/test_get_block_transaction_count.rs +++ b/unit_tests/tests/test_get_block_transaction_count.rs @@ -17,7 +17,7 @@ use unit_tests::constants::{DEOXYS, PATHFINDER}; #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_block_transaction_count(BlockId::Hash(FieldElement::ZERO)) @@ -44,9 +44,9 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_tag = BlockId::Tag(BlockTag::Latest); @@ -111,9 +111,9 @@ async fn work_with_block_1( #[rstest] #[tokio::test] async fn work_with_block_1_hash(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_hash = BlockId::Hash( FieldElement::from_hex_be( @@ -165,9 +165,9 @@ async fn work_with_block_100_000( #[rstest] #[tokio::test] async fn work_with_block_100_000_hash(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_hash = BlockId::Hash( FieldElement::from_hex_be( diff --git a/unit_tests/tests/test_get_block_with_tx_hashes.rs b/unit_tests/tests/test_get_block_with_tx_hashes.rs index 8a76c3c..da575c4 100644 --- a/unit_tests/tests/test_get_block_with_tx_hashes.rs +++ b/unit_tests/tests/test_get_block_with_tx_hashes.rs @@ -93,7 +93,7 @@ fn compare_json_values(path: &str, value1: &Value, value2: &Value) -> bool { #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_block_with_tx_hashes(BlockId::Hash(FieldElement::ZERO)) @@ -126,8 +126,8 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_number = BlockId::Number(193); @@ -192,8 +192,8 @@ async fn work_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_block_with_tx_hashes(BlockId::Tag(BlockTag::Pending)) diff --git a/unit_tests/tests/test_get_block_with_txs.rs b/unit_tests/tests/test_get_block_with_txs.rs index 7711835..711038c 100644 --- a/unit_tests/tests/test_get_block_with_txs.rs +++ b/unit_tests/tests/test_get_block_with_txs.rs @@ -17,7 +17,7 @@ use unit_tests::constants::DEOXYS; #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_block_with_txs(BlockId::Hash(FieldElement::ZERO)) @@ -44,8 +44,8 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_number = get_block_setting(); if block_number != BlockId::Tag(BlockTag::Latest) { @@ -95,8 +95,8 @@ async fn work_with_block_1( #[rstest] #[tokio::test] async fn work_with_block_one_hash(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_hash = BlockId::Hash( FieldElement::from_hex_be( @@ -132,8 +132,8 @@ async fn work_with_block_100_000( async fn work_with_block_one_hundred_thousand_hash( clients: HashMap>, ) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let block_hash = BlockId::Hash( FieldElement::from_hex_be( diff --git a/unit_tests/tests/test_get_class.rs b/unit_tests/tests/test_get_class.rs index f3621dd..40752f9 100644 --- a/unit_tests/tests/test_get_class.rs +++ b/unit_tests/tests/test_get_class.rs @@ -14,7 +14,7 @@ use std::collections::HashMap; async fn fail_non_existing_block( clients: HashMap>, ) -> Result<()> { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0) .map_err(|e| anyhow!("Invalid Contract Class Hash: {}", e))?; @@ -36,7 +36,7 @@ async fn fail_non_existing_block( #[rstest] #[tokio::test] async fn fail_non_existing_class_hash(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let unknown_contract_class_hash = FieldElement::from_hex_be("0x4269DEADBEEF").expect("Invalid Contract class hash"); @@ -68,8 +68,8 @@ async fn fail_non_existing_class_hash(clients: HashMap>, ) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V0) .expect("Invalid Contract Class Hash"); @@ -109,8 +109,8 @@ async fn work_ok_retrieving_class_for_contract_version_0( async fn work_ok_retrieving_class_for_contract_version_1( clients: HashMap>, ) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH_V1) .expect("Invalid Contract Class Hash"); diff --git a/unit_tests/tests/test_get_class_at.rs b/unit_tests/tests/test_get_class_at.rs index 91b0c65..e882306 100644 --- a/unit_tests/tests/test_get_class_at.rs +++ b/unit_tests/tests/test_get_class_at.rs @@ -19,7 +19,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_class_at( @@ -52,7 +52,7 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_class_at(BlockId::Tag(BlockTag::Latest), FieldElement::ZERO) @@ -85,8 +85,8 @@ async fn fail_non_existing_contract(clients: HashMap>, ) -> anyhow::Result<()> { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_class_at( diff --git a/unit_tests/tests/test_get_class_hash_at.rs b/unit_tests/tests/test_get_class_hash_at.rs index a1c98c1..3e188aa 100644 --- a/unit_tests/tests/test_get_class_hash_at.rs +++ b/unit_tests/tests/test_get_class_hash_at.rs @@ -20,7 +20,7 @@ use starknet_providers::{ #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_class_hash_at( @@ -55,7 +55,7 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_class_hash_at( @@ -86,8 +86,8 @@ async fn fail_non_existing_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let class_hash_deoxys = deoxys .get_class_hash_at( @@ -117,8 +117,8 @@ async fn work_block_latest(clients: HashMap #[tokio::test] #[ignore = "Pending fails some times when called on the cusp of being accepted, need virtual sequencer"] async fn work_block_pending(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let class_hash_deoxys = deoxys .get_class_hash_at( diff --git a/unit_tests/tests/test_get_nonce.rs b/unit_tests/tests/test_get_nonce.rs index 29ade41..3554f26 100644 --- a/unit_tests/tests/test_get_nonce.rs +++ b/unit_tests/tests/test_get_nonce.rs @@ -32,7 +32,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_nonce( @@ -65,7 +65,7 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_nonce( @@ -101,7 +101,7 @@ async fn fail_non_existing_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; //This contract was created at Block 500198, so need to be synced to this minimum block @@ -127,7 +127,7 @@ async fn work_erc721_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; //This contract was created at Block 500192, so need to be synced to this minimum block @@ -153,8 +153,8 @@ async fn work_erc20_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; //This contract was created at Block 500209, so need to be synced to this minimum block @@ -189,8 +189,8 @@ async fn work_account_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; //This contract was created at Block 500192, so need to be synced to this minimum block diff --git a/unit_tests/tests/test_get_state_update.rs b/unit_tests/tests/test_get_state_update.rs index 896af27..5801ebc 100644 --- a/unit_tests/tests/test_get_state_update.rs +++ b/unit_tests/tests/test_get_state_update.rs @@ -52,7 +52,7 @@ pub fn sort_state_update(state_update: StateUpdate) -> StateUpdate { #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys.get_state_update(BlockId::Number(0)).await; @@ -74,9 +74,9 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_number = BlockId::Number(0); @@ -114,9 +114,9 @@ async fn work_genesis_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_number = BlockId::Number(250000); @@ -155,9 +155,9 @@ async fn work_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; for i in 0..5 { let block_number = BlockId::Number(i * 10000); @@ -198,9 +198,9 @@ async fn work_loop_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_number = BlockId::Tag(BlockTag::Pending); let response_deoxys = deoxys @@ -238,9 +238,9 @@ async fn work_block_pending(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let block_number = BlockId::Tag(BlockTag::Latest); let response_deoxys = deoxys diff --git a/unit_tests/tests/test_get_storage_at.rs b/unit_tests/tests/test_get_storage_at.rs index 4a1f785..8ed7c5e 100644 --- a/unit_tests/tests/test_get_storage_at.rs +++ b/unit_tests/tests/test_get_storage_at.rs @@ -17,7 +17,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_storage_at( @@ -51,7 +51,7 @@ async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_storage_at( @@ -85,7 +85,7 @@ async fn fail_non_existing_contract(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_storage_at( @@ -108,8 +108,8 @@ async fn fail_invalid_storage_key(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; // TODO: get contract key from field name let response_deoxys = deoxys diff --git a/unit_tests/tests/test_get_transaction_by_block_id_and_index.rs b/unit_tests/tests/test_get_transaction_by_block_id_and_index.rs index 84e9201..0364b6a 100644 --- a/unit_tests/tests/test_get_transaction_by_block_id_and_index.rs +++ b/unit_tests/tests/test_get_transaction_by_block_id_and_index.rs @@ -16,7 +16,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_non_existent_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_transaction_by_block_id_and_index(BlockId::Hash(FieldElement::ZERO), 0) @@ -46,7 +46,7 @@ async fn fail_non_existent_block(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys .get_transaction_by_block_id_and_index(BlockId::Number(5000), 389) @@ -77,8 +77,8 @@ async fn fail_non_existent_block_index(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; // getting transaction through block number and index let response_deoxys = deoxys @@ -116,8 +116,8 @@ async fn work_deploy_invoke(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; // getting transaction through block number and index let response_deoxys = deoxys @@ -155,8 +155,8 @@ async fn work_deploy_l1_handler(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; // getting transaction through block number and index let response_deoxys = deoxys @@ -194,8 +194,8 @@ async fn work_deploy_declare(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; // getting transaction through block number and index let response_deoxys = deoxys diff --git a/unit_tests/tests/test_get_transaction_by_hash.rs b/unit_tests/tests/test_get_transaction_by_hash.rs index 0a13dc8..0083b0f 100644 --- a/unit_tests/tests/test_get_transaction_by_hash.rs +++ b/unit_tests/tests/test_get_transaction_by_hash.rs @@ -16,7 +16,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_non_existing_transaction(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys.get_transaction_by_hash(FieldElement::ZERO).await; @@ -45,8 +45,8 @@ async fn fail_non_existing_transaction(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_transaction_by_hash(FieldElement::from_hex_be(TRANSACTION_INVOKE).unwrap()) @@ -71,8 +71,8 @@ async fn work_transaction_invoke(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_transaction_by_hash(FieldElement::from_hex_be(TRANSACTION_L1_HANDLER).unwrap()) @@ -97,8 +97,8 @@ async fn work_transaction_l1_handler(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_transaction_by_hash(FieldElement::from_hex_be(TRANSACTION_DECLARE).unwrap()) @@ -125,8 +125,8 @@ async fn work_transaction_declare(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_transaction_by_hash(FieldElement::from_hex_be(TRANSACTION_DEPLOY_ACCOUNT).unwrap()) diff --git a/unit_tests/tests/test_get_transaction_receipt.rs b/unit_tests/tests/test_get_transaction_receipt.rs index e16cec2..fdb3e79 100644 --- a/unit_tests/tests/test_get_transaction_receipt.rs +++ b/unit_tests/tests/test_get_transaction_receipt.rs @@ -15,7 +15,7 @@ use starknet_providers::{ #[rstest] #[tokio::test] async fn fail_invalid_transaction_hash(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys.get_transaction_receipt(FieldElement::ZERO).await; diff --git a/unit_tests/tests/test_get_transaction_status.rs b/unit_tests/tests/test_get_transaction_status.rs index 4c2ac9a..5852061 100644 --- a/unit_tests/tests/test_get_transaction_status.rs +++ b/unit_tests/tests/test_get_transaction_status.rs @@ -18,7 +18,7 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn fail_invalid_transaction(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; + let deoxys = &clients[mainnet::network::DEOXYS]; let response_deoxys = deoxys.get_transaction_status(FieldElement::ZERO).await; @@ -47,8 +47,8 @@ async fn fail_invalid_transaction(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let response_deoxys = deoxys .get_transaction_status( @@ -84,8 +84,8 @@ async fn work_transaction_accepted_on_l1(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; let transaction_count = deoxys .get_block_transaction_count(BlockId::Tag(BlockTag::Latest)) @@ -125,8 +125,8 @@ async fn work_transaction_accepted_on_l2(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; //This contract was created at Block 500670, so need to be synced to this minimum block let response_deoxys = deoxys diff --git a/unit_tests/tests/test_spec_version.rs b/unit_tests/tests/test_spec_version.rs index cf0f603..e28b57c 100644 --- a/unit_tests/tests/test_spec_version.rs +++ b/unit_tests/tests/test_spec_version.rs @@ -16,9 +16,9 @@ use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; #[rstest] #[tokio::test] async fn test_spec_version_7_1(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let juno = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let juno = &clients[mainnet::network::JUNO]; let response_deoxys = deoxys .spec_version() diff --git a/unit_tests/tests/test_syncing.rs b/unit_tests/tests/test_syncing.rs index e8d5141..cdb8d3c 100644 --- a/unit_tests/tests/test_syncing.rs +++ b/unit_tests/tests/test_syncing.rs @@ -15,9 +15,9 @@ use std::collections::HashMap; #[rstest] #[tokio::test] async fn syncing(clients: HashMap>) { - let deoxys = &clients[DEOXYS]; - let pathfinder = &clients[PATHFINDER]; - let node_c = &clients[JUNO]; + let deoxys = &clients[mainnet::network::DEOXYS]; + let pathfinder = &clients[mainnet::network::PATHFINDER]; + let node_c = &clients[mainnet::network::JUNO]; let response_deoxys = deoxys .syncing() From d9a47dec9f25c6f90c5307bca13b74d5af21e833 Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 17 Jun 2024 17:40:47 +0200 Subject: [PATCH 2/4] added transaction constants --- .../src/constants/mainnet/transaction.rs | 47 +++++ unit_tests/src/constants/sepolia/block.rs | 19 -- unit_tests/src/constants/sepolia/constants.rs | 168 ------------------ 3 files changed, 47 insertions(+), 187 deletions(-) diff --git a/unit_tests/src/constants/mainnet/transaction.rs b/unit_tests/src/constants/mainnet/transaction.rs index e69de29..4ae3947 100644 --- a/unit_tests/src/constants/mainnet/transaction.rs +++ b/unit_tests/src/constants/mainnet/transaction.rs @@ -0,0 +1,47 @@ +/// +/// Random INVOKE_V0 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c) +/// +pub const TX_INVOKE_V0: &str = + "0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c"; + +/// +/// Random INVOKE_V1 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d) +/// +pub const TX_INVOKE_V1: &str = + "0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d"; + +/// +/// Random DECLARE_V0 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82) +/// +pub const TX_DECLARE_V0: &str = + "0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82"; + +/// +/// Random DECLARE_V1 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71) +/// +pub const TX_DECLARE_V1: &str = + "0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71"; + +/// +/// Random DECLARE_V2 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1) +/// +pub const TX_DECLARE_V2: &str = + "0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1"; + +/// +/// Random L1_HANDLER_V0 transaction +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a) +/// +pub const TX_L1_HANDLER_V0: &str = + "0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a"; diff --git a/unit_tests/src/constants/sepolia/block.rs b/unit_tests/src/constants/sepolia/block.rs index e7ee223..e69de29 100644 --- a/unit_tests/src/constants/sepolia/block.rs +++ b/unit_tests/src/constants/sepolia/block.rs @@ -1,19 +0,0 @@ -/// -/// Starknet Mainnet 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/src/constants/sepolia/constants.rs b/unit_tests/src/constants/sepolia/constants.rs index cf3ccb2..e69de29 100644 --- a/unit_tests/src/constants/sepolia/constants.rs +++ b/unit_tests/src/constants/sepolia/constants.rs @@ -1,168 +0,0 @@ -use once_cell::sync::Lazy; -use std::env; - -// Max block number used for testing fetched from environment variable MAX_BLOCK -pub static MAX_BLOCK: Lazy = Lazy::new(|| { - env::var("MAX_BLOCK") - .map(|val| val.parse().unwrap_or(0)) - .unwrap_or(0) -}); - -pub const DEOXYS: &str = "deoxys"; -pub const PATHFINDER: &str = "pathfinder"; -pub const JUNO: &str = "juno"; -pub const STARKGATE_ETH_CONTRACT_ADDR: &str = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; -pub const INVALID_CONTRACT_ADDR: &str = "0x4269DEADBEEF"; -pub const CONTRACT_ADDR: &str = - "0x03a20d4f7b4229e7c4863dab158b4d076d7f454b893d90a62011882dc4caca2a"; -pub const CONTRACT_KEY: &str = "0x00f920571b9f85bdd92a867cfdc73319d0f8836f0e69e06e4c5566b6203f75cc"; - -/// -/// Contract address for StarkGate ETH starknet bridge. -/// -/// Details concerning available methods can be found on [StarkScan](https://starkscan.co/contract/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7#read-write-contract) -/// -pub const STARKGATE_ETH_BRIDGE_ADDR: &str = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; - -/// -/// Contract address for Jediswap exchange. -/// -/// Details concerning available methods can be found on [StarkScan](https://starkscan.co/contract/0x041fd22b238fa21cfcf5dd45a8548974d8263b3a531a60388411c5e230f97023#read-write-contract): -/// -pub const JEDI_SWAP_ADDR: &str = - "0x041fd22b238fa21cfcf5dd45a8548974d8263b3a531a60388411c5e230f97023"; - -/// -/// Contract address for Starkgate USDC on Starknet. -/// -/// Details concerning this coin can be found on [StarkScan](https://starkscan.co/token/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8): -/// -pub const STARKGATE_USDC: &str = - "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"; - -/// -/// Contract address fpr Starkgate Ether on Starknet. -/// -/// Detail concerning this coin can be found on [StarkScan](https://starkscan.co/token/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7): -/// -pub const STARKGATE_ETHER: &str = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; - -/// -/// Random ERC721 Starknet contract address. -/// -/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x07fa9a8eacb89fb6cd0c7fe557e71c42a4b181ba328a9a04958136e6469c4e00) -/// -pub const CONTRACT_ERC721: &str = - "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af"; - -/// -/// Random ERC20 Starknet contract address. -/// -/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x04a5fdce70877b77f03aea8a29259176f88d5bea9d0ad8c0118f5316425e6ba0) -/// -pub const CONTRACT_ERC20: &str = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; - -/// -/// Random ACCOUNT Starknet contract address. -/// -/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x05e1eee30e79b4f592f444132526b2e2c7f505698e888c659e5f5def5a458c1a) -/// -pub const CONTRACT_ACCOUNT_CAIRO_ZERO: &str = - "0x0100104681e789e4211fba898262e1d6f6191bee797ce38a9e07fe8dec743574"; - -/// -/// Random PROXY ACCOUNT Starknet contract address. -/// -/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x05d7f4d55795b56ceb4dd93febe17954c7cfd5e15d7a79cb0cec067a713ac159) -/// -pub const CONTRACT_ACCOUNT_PROXY_CAIRO_ZERO: &str = - "0x036Ef6410243034cE315eC19E7ABFEB41052f39095EE3D5AFcC20D672b1C725F"; - -/// -/// Random legacy account using Cairo v0 -/// -/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x07076931c19d0ef52b847f9412c90a2ef999ff028f1005d2d069343061762fb7) -/// -pub const CONTRACT_LEGACY: &str = - "0x07076931c19d0ef52b847f9412c90a2ef999ff028f1005d2d069343061762fb7"; -pub const BLOCK_LEGACY: u64 = 2891; - -/// -/// INVOKE transaction accepted on L1, also transaction 1 at block 5000 -/// -/// Details concerning this transaction can be found on [StarkScan](https://starkscan.co/tx/0x0214840bad3099f95c40106097b8ef5fd16f06cb23efcdaec297398f77174597) -/// -pub const TRANSACTION_INVOKE: &str = - "0x0214840bad3099f95c40106097b8ef5fd16f06cb23efcdaec297398f77174597"; -pub const TRANSACTION_INVOKE_INDEX: u64 = 1; -pub const TRANSACTION_INVOKE_BLOCK_NB: u64 = 50000; - -/// -/// L1_HANDLER transaction accepted on L1, also transaction 57 at block 50000 -/// -/// Details concerning this transaction can be found on [StarkScan](https://starkscan.co/tx/0x05ca6470c37e943b0ae172a11359f7a457054319e8ae8771af32a1f397c7c208) -/// -pub const TRANSACTION_L1_HANDLER: &str = - "0x05ca6470c37e943b0ae172a11359f7a457054319e8ae8771af32a1f397c7c208"; -pub const TRANSACTION_L1_HANDLER_INDEX: u64 = 57; -pub const TRANSACTION_L1_HANDLER_BLOCK_NB: u64 = 50000; - -/// -/// DECLARE transaction accepted on L1, also transaction 44 at block 49990 -/// -/// Details concerning this transaction can be found on [StarkScan](https://starkscan.co/tx/0x056c0723ef6cde62f589bbf7c5c40897b6e3d9c13e960c5e7f28276d8e9c3229) -/// -pub const TRANSACTION_DECLARE: &str = - "0x056c0723ef6cde62f589bbf7c5c40897b6e3d9c13e960c5e7f28276d8e9c3229"; -pub const TRANSACTION_DECLARE_INDEX: u64 = 44; -pub const TRANSACTION_DECLARE_BLOCK_NB: u64 = 49990; - -/// -/// DEPLOY_ACCOUNT transaction accepted on L1, also transaction 0 at block 5000 -/// -/// Details concerning this transaction can be found on [StarkScan](https://starkscan.co/tx/0x0604e143591a6bff980f3141abdfc87f1ef3243785d251367cdaa7da5c337ba4) -/// -pub const TRANSACTION_DEPLOY_ACCOUNT: &str = - "0x0604e143591a6bff980f3141abdfc87f1ef3243785d251367cdaa7da5c337ba4"; -pub const TRANSACTION_DEPLOY_ACCOUNT_INDEX: u64 = 0; -pub const TRANSACTION_DEPLOY_ACCOUNT_BLOCK_NB: u64 = 50000; - -/// -/// Random reverted Starknet transaction -/// -/// Details concerning this transaction can be found on [StarkScan](https://starkscan.co/tx/0x016ed559467c50c12f225f348ca8895d54b91a499ad6f856cb6086e317c120ca) -/// -pub const TRANSACTION_REVERTED: &str = - "0x016ed559467c50c12f225f348ca8895d54b91a499ad6f856cb6086e317c120ca"; - -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"; - -/// -/// Value to be used as a payload for a message in the `estimate_message_fee` test. -/// -pub const ETHEREUM_ADDRESS: &str = ""; -pub const INVALID_ETHEREUM_ADDRESS: &str = ""; -pub const SELECTOR_NAME: &str = ""; - -/// -/// Value to be used as a signer for simulate_transaction tests. -/// -pub const SIGNER_PRIVATE: &str = ""; -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_7_0: &str = "0.7.0"; -pub const SPEC_0_7_1: &str = "0.7.1"; - From 6627f9225b6acc85fc266f9fff1493a722981600 Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 17 Jun 2024 17:55:16 +0200 Subject: [PATCH 3/4] added contract constants --- unit_tests/src/constants/mainnet/contract.rs | 50 +++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/unit_tests/src/constants/mainnet/contract.rs b/unit_tests/src/constants/mainnet/contract.rs index 7ed6a84..163a9dc 100644 --- a/unit_tests/src/constants/mainnet/contract.rs +++ b/unit_tests/src/constants/mainnet/contract.rs @@ -51,4 +51,52 @@ pub const CONTRACT_ERC20: &str = /// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32) pub const CONTRACT_ACCOUNT: &str = - "0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32"; \ No newline at end of file + "0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32"; + +/// +/// Random Cairo 0 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe) +/// +pub const CONTRACT_CAIRO_0: &str = + "0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe"; + +/// +/// Random Braavos account Cairo 0 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7) +/// +pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_0: &str = + "0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7"; + +/// +/// Random Braavos account Cairo 1 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e) +/// +pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_1: &str = + "0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e"; + +/// +/// Random Argent account Cairo 0 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0) +/// +pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_0: &str = + "0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0"; + +/// +/// Random Argent account Cairo 1 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba) +/// +pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_1: &str = + "0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba"; + +/// +/// Random ERC721 Cairo 0 contract address. +/// +/// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57) +/// +pub const CONTRACT_ERC721_CAIRO_0: &str = + "0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57"; From ce555b7aafb324abc0190cb6c18c56a6941661da Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 17 Jun 2024 17:56:54 +0200 Subject: [PATCH 4/4] added contract constants --- unit_tests/src/constants/mainnet/contract.rs | 26 +++++++------- unit_tests/src/constants/mainnet/mod.rs | 4 +-- unit_tests/src/constants/mainnet/network.rs | 2 +- .../src/constants/mainnet/transaction.rs | 35 ++++++++----------- unit_tests/src/constants/mod.rs | 2 +- unit_tests/src/constants/sepolia/block.rs | 1 + unit_tests/src/constants/sepolia/contract.rs | 1 + unit_tests/src/constants/sepolia/mod.rs | 4 +-- unit_tests/src/constants/sepolia/network.rs | 1 + .../src/constants/sepolia/transaction.rs | 1 + unit_tests/src/lib.rs | 5 +-- unit_tests/tests/test_get_block_with_txs.rs | 11 +++--- .../tests/test_get_transaction_by_hash.rs | 16 ++++++--- 13 files changed, 57 insertions(+), 52 deletions(-) diff --git a/unit_tests/src/constants/mainnet/contract.rs b/unit_tests/src/constants/mainnet/contract.rs index 163a9dc..61cc895 100644 --- a/unit_tests/src/constants/mainnet/contract.rs +++ b/unit_tests/src/constants/mainnet/contract.rs @@ -48,55 +48,55 @@ pub const CONTRACT_ERC20: &str = /// /// Random ACCOUNT Starknet contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32) pub const CONTRACT_ACCOUNT: &str = "0x046ef77bd47ba7b1424ba2b2b1442d14168ac3dc6897032bf491ecbafd5f5c32"; /// /// Random Cairo 0 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe) -/// +/// pub const CONTRACT_CAIRO_0: &str = "0x03cdabdf2ea700a667c63024523ccb04a22d18104da826ac10984a18eddadbbe"; /// /// Random Braavos account Cairo 0 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7) -/// +/// pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_0: &str = "0x0179d67854d1b9429d276ed7c59010be187af15d2e6ede31a513bdfbfa3e1af7"; /// /// Random Braavos account Cairo 1 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e) -/// +/// pub const CONTRACT_BRAAVOS_ACCOUNT_CAIRO_1: &str = "0x017de82f930be1caec165b9501197046ecc7d2d86d9721cd57f0cb16c2a99b2e"; /// /// Random Argent account Cairo 0 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0) -/// +/// pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_0: &str = "0x0314a5cbf7f368446d38ed4d0de19f5ca16546c1a519e8994c07590ecff803c0"; /// /// Random Argent account Cairo 1 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba) -/// +/// pub const CONTRACT_ARGENT_ACCOUNT_CAIRO_1: &str = "0x017317d13c8278d38720d2d70d7adcf6a3cf9ef3abb5422ad60ea4f98f8d6eba"; /// /// Random ERC721 Cairo 0 contract address. -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/contract/0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57) -/// +/// pub const CONTRACT_ERC721_CAIRO_0: &str = "0x0717e6b64e3c48c016ffec829963696480bf40ad8ca1d5303902c1b23347ff57"; diff --git a/unit_tests/src/constants/mainnet/mod.rs b/unit_tests/src/constants/mainnet/mod.rs index eb58750..e20aad3 100644 --- a/unit_tests/src/constants/mainnet/mod.rs +++ b/unit_tests/src/constants/mainnet/mod.rs @@ -1,4 +1,4 @@ pub mod block; -pub mod transaction; +pub mod contract; pub mod network; -pub mod contract; \ No newline at end of file +pub mod transaction; diff --git a/unit_tests/src/constants/mainnet/network.rs b/unit_tests/src/constants/mainnet/network.rs index 0351fed..90a1fbe 100644 --- a/unit_tests/src/constants/mainnet/network.rs +++ b/unit_tests/src/constants/mainnet/network.rs @@ -1,3 +1,3 @@ pub const DEOXYS: &str = "deoxys"; pub const PATHFINDER: &str = "pathfinder"; -pub const JUNO: &str = "juno"; \ No newline at end of file +pub const JUNO: &str = "juno"; diff --git a/unit_tests/src/constants/mainnet/transaction.rs b/unit_tests/src/constants/mainnet/transaction.rs index 4ae3947..bf6fdba 100644 --- a/unit_tests/src/constants/mainnet/transaction.rs +++ b/unit_tests/src/constants/mainnet/transaction.rs @@ -1,47 +1,42 @@ /// /// Random INVOKE_V0 transaction -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c) -/// -pub const TX_INVOKE_V0: &str = - "0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c"; +/// +pub const TX_INVOKE_V0: &str = "0x02c02d6f0d75bc71b1c629cde038199ccfb6e18343a76943275405817727f76c"; /// /// Random INVOKE_V1 transaction /// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d) /// -pub const TX_INVOKE_V1: &str = - "0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d"; +pub const TX_INVOKE_V1: &str = "0x027ed707907aef09c39ece1b24540308eee8d74a14c77728604c3a2da546fd6d"; /// /// Random DECLARE_V0 transaction -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82) -/// -pub const TX_DECLARE_V0: &str = - "0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82"; +/// +pub const TX_DECLARE_V0: &str = "0x5f430525084fe54a73e6f6de7d5d3ac20311ac4ba48002c665dade0c585af82"; /// /// Random DECLARE_V1 transaction -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71) /// -pub const TX_DECLARE_V1: &str = - "0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71"; - +pub const TX_DECLARE_V1: &str = "0x30fd34d7ffbe2aea6121f76c7c82a9edb7250a69a86eaf4ea55e9fb39237d71"; + /// /// Random DECLARE_V2 transaction -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1) -/// -pub const TX_DECLARE_V2: &str = - "0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1"; +/// +pub const TX_DECLARE_V2: &str = "0x62c6e41b306db3dd03fbbb14bd169e84819e5ac1058ffde93a924b3abe9b3c1"; /// /// Random L1_HANDLER_V0 transaction -/// +/// /// Details concerning this contract can be found on [StarkScan](https://starkscan.co/tx/0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a) -/// +/// pub const TX_L1_HANDLER_V0: &str = "0x006a555ac598673a215ef69815db1ebe89cb11eed9a489215c21c7d32d6e581a"; diff --git a/unit_tests/src/constants/mod.rs b/unit_tests/src/constants/mod.rs index 8a17b48..11d26b2 100644 --- a/unit_tests/src/constants/mod.rs +++ b/unit_tests/src/constants/mod.rs @@ -1,2 +1,2 @@ pub mod mainnet; -pub mod sepolia; \ No newline at end of file +pub mod sepolia; diff --git a/unit_tests/src/constants/sepolia/block.rs b/unit_tests/src/constants/sepolia/block.rs index e69de29..8b13789 100644 --- a/unit_tests/src/constants/sepolia/block.rs +++ b/unit_tests/src/constants/sepolia/block.rs @@ -0,0 +1 @@ + diff --git a/unit_tests/src/constants/sepolia/contract.rs b/unit_tests/src/constants/sepolia/contract.rs index e69de29..8b13789 100644 --- a/unit_tests/src/constants/sepolia/contract.rs +++ b/unit_tests/src/constants/sepolia/contract.rs @@ -0,0 +1 @@ + diff --git a/unit_tests/src/constants/sepolia/mod.rs b/unit_tests/src/constants/sepolia/mod.rs index eb58750..e20aad3 100644 --- a/unit_tests/src/constants/sepolia/mod.rs +++ b/unit_tests/src/constants/sepolia/mod.rs @@ -1,4 +1,4 @@ pub mod block; -pub mod transaction; +pub mod contract; pub mod network; -pub mod contract; \ No newline at end of file +pub mod transaction; diff --git a/unit_tests/src/constants/sepolia/network.rs b/unit_tests/src/constants/sepolia/network.rs index e69de29..8b13789 100644 --- a/unit_tests/src/constants/sepolia/network.rs +++ b/unit_tests/src/constants/sepolia/network.rs @@ -0,0 +1 @@ + diff --git a/unit_tests/src/constants/sepolia/transaction.rs b/unit_tests/src/constants/sepolia/transaction.rs index e69de29..8b13789 100644 --- a/unit_tests/src/constants/sepolia/transaction.rs +++ b/unit_tests/src/constants/sepolia/transaction.rs @@ -0,0 +1 @@ + diff --git a/unit_tests/src/lib.rs b/unit_tests/src/lib.rs index da0b1db..785ba40 100644 --- a/unit_tests/src/lib.rs +++ b/unit_tests/src/lib.rs @@ -1,5 +1,6 @@ #![feature(assert_matches)] +use constants::mainnet; use starknet_accounts::{Account, Call, ConnectedAccount, Execution, SingleOwnerAccount}; use starknet_core::chain_id; use starknet_core::types::BroadcastedInvokeTransaction; @@ -9,7 +10,6 @@ use starknet_core::{ }; use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient}; use starknet_signers::{LocalWallet, SigningKey}; -use constants::mainnet; pub mod constants; pub mod fixtures; @@ -28,7 +28,8 @@ impl TransactionFactory for OkTransactionFactory { max_fee: FieldElement::ZERO, signature: vec![], nonce: nonce.unwrap_or(FieldElement::ZERO), - sender_address: FieldElement::from_hex_be(mainnet::contract::CONTRACT_ACCOUNT).unwrap(), + sender_address: FieldElement::from_hex_be(mainnet::contract::CONTRACT_ACCOUNT) + .unwrap(), calldata: vec![ FieldElement::from_hex_be(mainnet::contract::CONTRACT_ERC20).unwrap(), get_selector_from_name("transfer").unwrap(), diff --git a/unit_tests/tests/test_get_block_with_txs.rs b/unit_tests/tests/test_get_block_with_txs.rs index 26b6f4c..96f4a25 100644 --- a/unit_tests/tests/test_get_block_with_txs.rs +++ b/unit_tests/tests/test_get_block_with_txs.rs @@ -4,13 +4,13 @@ mod common; use colored::*; use common::*; use serde_json::Value; -use std::sync::Arc; -use std::collections::HashMap; use starknet_core::types::{BlockId, BlockTag, FieldElement, StarknetError}; use starknet_providers::{ jsonrpc::{HttpTransport, JsonRpcClient}, Provider, }; +use std::collections::HashMap; +use std::sync::Arc; use unit_tests::constants::DEOXYS; // Define a recursive function to compare JSON values and print differences @@ -156,7 +156,6 @@ async fn work_with_latest_block(clients: HashMap, pathfinder: JsonRpcClient, @@ -270,9 +269,7 @@ async fn work_with_block_100_000( #[rstest] #[tokio::test] async fn work_with_block_one_hundred_thousand_hash( - clients - -: HashMap>, + clients: HashMap>, ) { let deoxys = &clients[mainnet::network::DEOXYS]; let pathfinder = &clients[mainnet::network::PATHFINDER]; @@ -418,4 +415,4 @@ async fn work_loop(deoxys: JsonRpcClient, pathfinder: JsonRpcClie } } assert_eq!(diff, false); -} \ No newline at end of file +} diff --git a/unit_tests/tests/test_get_transaction_by_hash.rs b/unit_tests/tests/test_get_transaction_by_hash.rs index 7b381d6..d92c68b 100644 --- a/unit_tests/tests/test_get_transaction_by_hash.rs +++ b/unit_tests/tests/test_get_transaction_by_hash.rs @@ -101,12 +101,16 @@ async fn work_declare_transaction(clients: HashMap