diff --git a/Cargo.lock b/Cargo.lock index 59b80f23c..ea7c74289 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aes" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - [[package]] name = "ahash" version = "0.7.7" @@ -82,21 +71,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anstream" version = "0.6.4" @@ -428,30 +402,12 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" -[[package]] -name = "bigdecimal" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits 0.2.17", - "serde", -] - [[package]] name = "bincode" version = "2.0.0-rc.3" @@ -1184,29 +1140,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits 0.2.17", - "serde", - "windows-targets 0.48.5", -] - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "clap" version = "4.4.8" @@ -1475,15 +1408,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher", -] - [[package]] name = "darling" version = "0.14.4" @@ -1596,7 +1520,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -1807,55 +1730,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "eth-keystore" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" -dependencies = [ - "aes", - "ctr", - "digest", - "hex", - "hmac", - "pbkdf2", - "rand", - "scrypt", - "serde", - "serde_json", - "sha2", - "sha3", - "thiserror", - "uuid", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "impl-serde", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint", -] - [[package]] name = "expect-test" version = "1.4.1" @@ -1893,18 +1767,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -3123,29 +2985,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "id-arena" version = "2.2.1" @@ -3194,33 +3033,6 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -3298,15 +3110,6 @@ version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - [[package]] name = "instant" version = "0.1.12" @@ -3960,7 +3763,6 @@ dependencies = [ "bitvec", "byte-slice-cast", "impl-trait-for-tuples", - "parity-scale-codec-derive", "serde", ] @@ -4054,15 +3856,6 @@ dependencies = [ "camino", ] -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -4187,19 +3980,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "uint", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -4434,7 +4214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "async-compression", - "base64 0.21.5", + "base64", "bytes", "encoding_rs", "futures-core", @@ -4470,7 +4250,6 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots", "winreg", ] @@ -4498,16 +4277,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rustc-hex", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -4520,12 +4289,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - [[package]] name = "rustc_version" version = "0.4.0" @@ -4578,7 +4341,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.5", + "base64", ] [[package]] @@ -4632,15 +4395,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "salsa20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" -dependencies = [ - "cipher", -] - [[package]] name = "same-file" version = "1.0.6" @@ -4848,7 +4602,6 @@ dependencies = [ "serde", "serde_json", "smol_str", - "starknet", "thiserror", "walkdir", ] @@ -4936,18 +4689,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scrypt" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" -dependencies = [ - "hmac", - "pbkdf2", - "salsa20", - "sha2", -] - [[package]] name = "sct" version = "0.7.1" @@ -5052,17 +4793,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_json_pythonic" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62212da9872ca2a0cad0093191ee33753eddff9266cbbc1b4a602d13a3a768db" -dependencies = [ - "itoa", - "ryu", - "serde", -] - [[package]] name = "serde_path_to_error" version = "0.1.14" @@ -5114,34 +4844,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "base64 0.13.1", - "chrono", - "hex", - "indexmap 1.9.3", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling 0.20.3", - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "sha1_smol" version = "1.0.0" @@ -5322,87 +5024,6 @@ dependencies = [ "num-traits 0.1.43", ] -[[package]] -name = "starknet" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0623b045f3dc10aef030c9ddd4781cff9cbe1188b71063cc510b75d1f96be6" -dependencies = [ - "starknet-accounts", - "starknet-contract", - "starknet-core 0.6.1", - "starknet-crypto 0.6.1", - "starknet-ff", - "starknet-macros", - "starknet-providers", - "starknet-signers", -] - -[[package]] -name = "starknet-accounts" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e97edc480348dca300e5a8234e6c4e6f2f1ac028f2b16fcce294ebe93d07f4" -dependencies = [ - "async-trait", - "auto_impl", - "starknet-core 0.6.1", - "starknet-providers", - "starknet-signers", - "thiserror", -] - -[[package]] -name = "starknet-contract" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b86e3f6b3ca9a5c45271ab10871c99f7dc82fee3199d9f8c7baa2a1829947d" -dependencies = [ - "serde", - "serde_json", - "serde_with", - "starknet-accounts", - "starknet-core 0.6.1", - "starknet-providers", - "thiserror", -] - -[[package]] -name = "starknet-core" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" -dependencies = [ - "base64 0.21.5", - "flate2", - "hex", - "serde", - "serde_json", - "serde_json_pythonic", - "serde_with", - "sha3", - "starknet-crypto 0.6.1", - "starknet-ff", -] - -[[package]] -name = "starknet-core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1683ca7c63f0642310eddedb7d35056d8306084dff323d440711065c63ed87" -dependencies = [ - "base64 0.21.5", - "flate2", - "hex", - "serde", - "serde_json", - "serde_json_pythonic", - "serde_with", - "sha3", - "starknet-crypto 0.6.1", - "starknet-ff", -] - [[package]] name = "starknet-crypto" version = "0.5.2" @@ -5479,58 +5100,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7584bc732e4d2a8ccebdd1dda8236f7940a79a339e30ebf338d45c329659e36c" dependencies = [ "ark-ff", - "bigdecimal", "crypto-bigint", "getrandom", "hex", - "num-bigint", - "serde", -] - -[[package]] -name = "starknet-macros" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66fe05edab7ee6752a0aff3e14508001191083f3c6d0b6fa14f7008a96839b0" -dependencies = [ - "starknet-core 0.7.2", - "syn 2.0.39", -] - -[[package]] -name = "starknet-providers" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b136c26b72ff1756f0844e0aa80bab680ceb99d63921826facbb8e7340ff82" -dependencies = [ - "async-trait", - "auto_impl", - "ethereum-types", - "flate2", - "log", - "reqwest", - "serde", - "serde_json", - "serde_with", - "starknet-core 0.6.1", - "thiserror", - "url", -] - -[[package]] -name = "starknet-signers" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9386015d2e6dc3df285bfb33a3afd8ad7596c70ed38ab57019de4d2dfc7826f" -dependencies = [ - "async-trait", - "auto_impl", - "crypto-bigint", - "eth-keystore", - "rand", - "starknet-core 0.6.1", - "starknet-crypto 0.6.1", - "thiserror", ] [[package]] @@ -6110,18 +5682,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "uluru" version = "3.0.0" @@ -6218,16 +5778,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom", - "serde", -] - [[package]] name = "valuable" version = "0.1.0" @@ -6369,12 +5919,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - [[package]] name = "which" version = "5.0.0" @@ -6428,15 +5972,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index b2dce1e04..3cada3608 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,7 +101,6 @@ similar-asserts = { version = "1", features = ["serde"] } smallvec = "1" smol_str = { version = "0.2", features = ["serde"] } snapbox = { version = "0.4", features = ["cmd", "path"] } -starknet = "0.6" syn = "2" tar = "0.4" tempfile = "3" diff --git a/extensions/scarb-snforge-test-collector/Cargo.toml b/extensions/scarb-snforge-test-collector/Cargo.toml index a2f49b291..a8a96e57e 100644 --- a/extensions/scarb-snforge-test-collector/Cargo.toml +++ b/extensions/scarb-snforge-test-collector/Cargo.toml @@ -37,6 +37,5 @@ scarb-ui = { path = "../../utils/scarb-ui" } serde.workspace = true serde_json.workspace = true smol_str.workspace = true -starknet.workspace = true thiserror.workspace = true walkdir.workspace = true diff --git a/extensions/scarb-snforge-test-collector/src/compilation/test_collector.rs b/extensions/scarb-snforge-test-collector/src/compilation/test_collector.rs index 9877715ce..6d4c83b05 100644 --- a/extensions/scarb-snforge-test-collector/src/compilation/test_collector.rs +++ b/extensions/scarb-snforge-test-collector/src/compilation/test_collector.rs @@ -27,16 +27,15 @@ use smol_str::SmolStr; use std::path::{Path, PathBuf}; use std::sync::Arc; -use crate::compilation::test_collector::config::ExpectedTestResult; +use crate::compilation::test_collector::config::{ExpectedTestResult, RawForkConfig}; use crate::metadata::CompilationUnit; -pub use config::RawForkConfig; use config::{forge_try_extract_test_config, FuzzerConfig, SingleTestConfig}; +use function_finder::FunctionFinder; use plugin::snforge_test_plugin_suite; -use sierra_casm_generator::FunctionFinder; mod config; +mod function_finder; mod plugin; -mod sierra_casm_generator; fn find_all_tests( db: &dyn SemanticGroup, diff --git a/extensions/scarb-snforge-test-collector/src/compilation/test_collector/config.rs b/extensions/scarb-snforge-test-collector/src/compilation/test_collector/config.rs index 13cc24450..9819c6b5d 100644 --- a/extensions/scarb-snforge-test-collector/src/compilation/test_collector/config.rs +++ b/extensions/scarb-snforge-test-collector/src/compilation/test_collector/config.rs @@ -2,7 +2,7 @@ use anyhow::Result; use cairo_felt::Felt252; use cairo_lang_defs::plugin::PluginDiagnostic; use cairo_lang_syntax::attribute::structured::{Attribute, AttributeArg, AttributeArgVariant}; -use cairo_lang_syntax::node::ast::{ArgClause, Expr}; +use cairo_lang_syntax::node::ast::{ArgClause, Expr, PathSegment}; use cairo_lang_syntax::node::db::SyntaxGroup; use cairo_lang_syntax::node::helpers::GetIdentifier; use cairo_lang_test_plugin::test_config::{PanicExpectation, TestExpectation}; @@ -10,8 +10,7 @@ use cairo_lang_test_plugin::{try_extract_test_config, TestConfig}; use cairo_lang_utils::OptionHelper; use num_bigint::BigInt; use num_traits::ToPrimitive; -use serde::{Deserialize, Serialize}; -use starknet::core::types::{BlockId, BlockTag, FieldElement}; +use serde::Serialize; const AVAILABLE_GAS_ATTR: &str = "available_gas"; const FORK_ATTR: &str = "fork"; @@ -55,19 +54,20 @@ impl From for ExpectedTestResult { } } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub enum RawForkConfig { Id(String), Params(RawForkParams), } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct RawForkParams { pub url: String, - pub block_id: BlockId, + pub block_id_type: String, + pub block_id_value: String, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct FuzzerConfig { pub fuzzer_runs: u32, pub fuzzer_seed: u64, @@ -284,60 +284,56 @@ fn extract_fork_config_from_args(db: &dyn SyntaxGroup, attr: &Attribute) -> Opti return None; } - let block_id_type = block_id - .path(db) - .elements(db) - .last() - .unwrap() - .identifier(db) - .to_string(); + let block_id_type = elements[1].clone(); let args = block_id.arguments(db).arguments(db).elements(db); let expr = match args.first()?.arg_clause(db) { ArgClause::Unnamed(unnamed_arg_clause) => Some(unnamed_arg_clause.value(db)), _ => None, }?; - let block_id = try_get_block_id(db, &block_id_type, &expr)?; + let block_id_value = try_get_block_id(db, &block_id_type, &expr)?; - Some(RawForkConfig::Params(RawForkParams { url, block_id })) + Some(RawForkConfig::Params(RawForkParams { + url, + block_id_type, + block_id_value, + })) } -fn try_get_block_id(db: &dyn SyntaxGroup, block_id_type: &str, expr: &Expr) -> Option { +fn try_get_block_id(db: &dyn SyntaxGroup, block_id_type: &str, expr: &Expr) -> Option { match block_id_type { "Number" => { if let Expr::Literal(value) = expr { - return Some(BlockId::Number( - u64::try_from(value.numeric_value(db).unwrap()).ok()?, - )); + return Some( + u64::try_from(value.numeric_value(db).unwrap()) + .ok()? + .to_string(), + ); } - None } "Hash" => { + // TODO #1179: add range check if let Expr::Literal(value) = expr { - return Some(BlockId::Hash( - FieldElement::from_bytes_be( - &Felt252::from(value.numeric_value(db).unwrap()).to_be_bytes(), - ) - .unwrap(), - )); + return Some(value.numeric_value(db).unwrap().to_string()); } - None } "Tag" => { if let Expr::Path(block_tag) = expr { - let tag = block_tag - .elements(db) - .last() - .unwrap() - .identifier(db) - .to_string(); - return match tag.as_str() { - "Latest" => Some(BlockId::Tag(BlockTag::Latest)), - _ => None, - }; + let tag_elements = block_tag.elements(db); + if tag_path_is_valid(&tag_elements, db) { + return Some("Latest".to_string()); + } } - None } - _ => None, - } + _ => (), + }; + + None +} + +// Only valid options are `BlockTag::Latest` and `Latest` +fn tag_path_is_valid(tag_elements: &[PathSegment], db: &dyn SyntaxGroup) -> bool { + (tag_elements.len() == 1 + || (tag_elements.len() == 2 && tag_elements[0].identifier(db).as_str() == "BlockTag")) + && tag_elements.last().unwrap().identifier(db).as_str() == "Latest" } diff --git a/extensions/scarb-snforge-test-collector/src/compilation/test_collector/sierra_casm_generator.rs b/extensions/scarb-snforge-test-collector/src/compilation/test_collector/function_finder.rs similarity index 100% rename from extensions/scarb-snforge-test-collector/src/compilation/test_collector/sierra_casm_generator.rs rename to extensions/scarb-snforge-test-collector/src/compilation/test_collector/function_finder.rs