diff --git a/Cargo.lock b/Cargo.lock index b1f78beb6..0f175579d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3421,7 +3421,6 @@ version = "0.0.0" dependencies = [ "assert_matches", "blockifier 0.8.0-rc.0 (git+https://github.com/starkware-libs/blockifier.git?rev=32191d41)", - "rstest", "serde_json", "starknet-types-core", "starknet_api", diff --git a/crates/gateway/src/compilation_test.rs b/crates/gateway/src/compilation_test.rs index 913f71857..c7a364e8c 100644 --- a/crates/gateway/src/compilation_test.rs +++ b/crates/gateway/src/compilation_test.rs @@ -1,7 +1,7 @@ use assert_matches::assert_matches; use blockifier::execution::contract_class::ContractClass; use cairo_lang_starknet_classes::allowed_libfuncs::AllowedLibfuncsError; -use mempool_test_utils::starknet_api_test_utils::declare_tx; +use mempool_test_utils::starknet_api_test_utils::declare_tx as rpc_declare_tx; use rstest::{fixture, rstest}; use starknet_api::core::CompiledClassHash; use starknet_api::rpc_transaction::{RPCDeclareTransaction, RPCTransaction}; @@ -15,13 +15,21 @@ fn gateway_compiler() -> GatewayCompiler { GatewayCompiler { config: Default::default() } } +#[fixture] +fn declare_tx() -> RPCDeclareTransaction { + assert_matches!( + rpc_declare_tx(), + RPCTransaction::Declare(declare_tx) => declare_tx + ) +} + // TODO(Arni): Redesign this test once the compiler is passed with dependancy injection. #[rstest] -fn test_compile_contract_class_compiled_class_hash_mismatch(gateway_compiler: GatewayCompiler) { - let mut tx = assert_matches!( - declare_tx(), - RPCTransaction::Declare(RPCDeclareTransaction::V3(tx)) => tx - ); +fn test_compile_contract_class_compiled_class_hash_mismatch( + gateway_compiler: GatewayCompiler, + declare_tx: RPCDeclareTransaction, +) { + let RPCDeclareTransaction::V3(mut tx) = declare_tx; let expected_hash = tx.compiled_class_hash; let wrong_supplied_hash = CompiledClassHash::default(); tx.compiled_class_hash = wrong_supplied_hash; @@ -36,11 +44,11 @@ fn test_compile_contract_class_compiled_class_hash_mismatch(gateway_compiler: Ga } #[rstest] -fn test_compile_contract_class_bad_sierra(gateway_compiler: GatewayCompiler) { - let mut tx = assert_matches!( - declare_tx(), - RPCTransaction::Declare(RPCDeclareTransaction::V3(tx)) => tx - ); +fn test_compile_contract_class_bad_sierra( + gateway_compiler: GatewayCompiler, + declare_tx: RPCDeclareTransaction, +) { + let RPCDeclareTransaction::V3(mut tx) = declare_tx; // Truncate the sierra program to trigger an error. tx.contract_class.sierra_program = tx.contract_class.sierra_program[..100].to_vec(); let declare_tx = RPCDeclareTransaction::V3(tx); @@ -55,11 +63,10 @@ fn test_compile_contract_class_bad_sierra(gateway_compiler: GatewayCompiler) { } #[rstest] -fn test_process_declare_tx_success(gateway_compiler: GatewayCompiler) { - let declare_tx = assert_matches!( - declare_tx(), - RPCTransaction::Declare(declare_tx) => declare_tx - ); +fn test_process_declare_tx_success( + gateway_compiler: GatewayCompiler, + declare_tx: RPCDeclareTransaction, +) { let RPCDeclareTransaction::V3(declare_tx_v3) = &declare_tx; let contract_class = &declare_tx_v3.contract_class; diff --git a/crates/mempool_test_utils/Cargo.toml b/crates/mempool_test_utils/Cargo.toml index cb8a0d170..4385ec6cd 100644 --- a/crates/mempool_test_utils/Cargo.toml +++ b/crates/mempool_test_utils/Cargo.toml @@ -10,7 +10,6 @@ license.workspace = true [dependencies] assert_matches.workspace = true blockifier = { workspace = true, features = ["testing"] } -rstest.workspace = true starknet-types-core.workspace = true starknet_api.workspace = true serde_json.workspace = true