From ffca06093ade0f908388d30ca24ddb8c8ec79652 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Wed, 22 May 2024 08:40:13 +0300 Subject: [PATCH] test: remove redundent mempool node config tests --- crates/mempool_node/src/config/config_test.rs | 31 ++------ .../src/test_files/mempool_node_config.json | 72 ------------------- 2 files changed, 4 insertions(+), 99 deletions(-) delete mode 100644 crates/mempool_node/src/test_files/mempool_node_config.json diff --git a/crates/mempool_node/src/config/config_test.rs b/crates/mempool_node/src/config/config_test.rs index b8b9bb4be..7ce3c2cc0 100644 --- a/crates/mempool_node/src/config/config_test.rs +++ b/crates/mempool_node/src/config/config_test.rs @@ -1,12 +1,9 @@ #![allow(unused_imports)] use std::env::{self, args}; use std::fs::File; -use std::ops::IndexMut; -use std::path::{Path, PathBuf}; use assert_matches::assert_matches; use papyrus_config::dumping::SerializeConfig; -use papyrus_config::loading::load_and_process_config; use papyrus_config::presentation::get_config_presentation; use papyrus_config::validators::ParsedValidationErrors; use papyrus_config::{SerializationType, SerializedContent, SerializedParam}; @@ -15,22 +12,12 @@ use starknet_gateway::config::{ }; use validator::Validate; -use crate::config::{ - node_command, ComponentConfig, ComponentExecutionConfig, GatewayConfig, MempoolNodeConfig, -}; - -const TEST_FILES_FOLDER: &str = "./src/test_files"; -const CONFIG_FILE: &str = "mempool_node_config.json"; - -fn get_config_file(file_name: &str) -> Result { - let config_file = File::open(Path::new(TEST_FILES_FOLDER).join(file_name)).unwrap(); - load_and_process_config::(config_file, node_command(), vec![]) -} +use crate::config::{ComponentConfig, ComponentExecutionConfig, GatewayConfig, MempoolNodeConfig}; #[test] -fn test_valid_config() { - // Read the valid config file and validate its content. - let expected_config = MempoolNodeConfig { +fn test_components_config() { + // Initialize the config file and check that the validator finds no errors. + let mut config = MempoolNodeConfig { components: ComponentConfig { gateway_component: ComponentExecutionConfig { execute: true }, mempool_component: ComponentExecutionConfig { execute: false }, @@ -47,16 +34,6 @@ fn test_valid_config() { StatefulTransactionValidatorConfig::create_for_testing(), }, }; - let loaded_config = get_config_file(CONFIG_FILE).unwrap(); - - assert!(loaded_config.validate().is_ok()); - assert_eq!(loaded_config, expected_config); -} - -#[test] -fn test_components_config() { - // Read the valid config file and check that the validator finds no errors. - let mut config = get_config_file(CONFIG_FILE).unwrap(); assert!(config.validate().is_ok()); // Invalidate the gateway component and check that the validator finds an error. diff --git a/crates/mempool_node/src/test_files/mempool_node_config.json b/crates/mempool_node/src/test_files/mempool_node_config.json deleted file mode 100644 index 5e7ae882f..000000000 --- a/crates/mempool_node/src/test_files/mempool_node_config.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "components.gateway_component.execute": { - "description": "The component execution flag.", - "privacy": "Public", - "value": true - }, - "components.mempool_component.execute": { - "description": "The component execution flag.", - "privacy": "Public", - "value": false - }, - "gateway_config.network_config.ip": { - "description": "The gateway server ip.", - "privacy": "Public", - "value": "0.0.0.0" - }, - "gateway_config.network_config.port": { - "description": "The gateway server port.", - "privacy": "Public", - "value": 8080 - }, - "gateway_config.stateful_transaction_validator_config.chain_info.chain_id": { - "description": "The chain ID of the StarkNet chain.", - "privacy": "Public", - "value": "SN_GOERLI" - }, - "gateway_config.stateful_transaction_validator_config.chain_info.eth_fee_token_address": { - "description": "Address of the ETH fee token.", - "privacy": "Public", - "value": "0x1001" - }, - "gateway_config.stateful_transaction_validator_config.chain_info.strk_fee_token_address": { - "description": "Address of the STRK fee token.", - "privacy": "Public", - "value": "0x1002" - }, - "gateway_config.stateful_transaction_validator_config.max_nonce_for_validation_skip": { - "description": "The maximum nonce for which the validation is skipped.", - "privacy": "Public", - "value": "0x0" - }, - "gateway_config.stateful_transaction_validator_config.max_recursion_depth": { - "description": "The maximum recursion depth allowed in a transaction.", - "privacy": "Public", - "value": 50 - }, - "gateway_config.stateful_transaction_validator_config.validate_max_n_steps": { - "description": "The maximum number of steps the validation function is allowed to take.", - "privacy": "Public", - "value": 1000000 - }, - "gateway_config.stateless_transaction_validator_config.max_calldata_length": { - "description": "Validates that a transaction has signature length less than or equal to this value.", - "privacy": "Public", - "value": 10 - }, - "gateway_config.stateless_transaction_validator_config.max_signature_length": { - "description": "Validates that a transaction has calldata length less than or equal to this value.", - "privacy": "Public", - "value": 2 - }, - "gateway_config.stateless_transaction_validator_config.validate_non_zero_l1_gas_fee": { - "description": "If true, validates that a transaction has non-zero L1 resource bounds.", - "privacy": "Public", - "value": true - }, - "gateway_config.stateless_transaction_validator_config.validate_non_zero_l2_gas_fee": { - "description": "If true, validates that a transaction has non-zero L2 resource bounds.", - "privacy": "Public", - "value": false - } -} \ No newline at end of file