Skip to content

Commit

Permalink
test: remove redundent mempool node config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed May 26, 2024
1 parent 8a18c5d commit 405a4cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 109 deletions.
31 changes: 4 additions & 27 deletions crates/mempool_node/src/config/config_test.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
#[cfg(any(feature = "testing", test))]
use std::fs::File;
use std::path::Path;

use assert_matches::assert_matches;
use papyrus_config::loading::load_and_process_config;
use papyrus_config::validators::ParsedValidationErrors;
use starknet_gateway::config::{
GatewayNetworkConfig, RpcStateReaderConfig, StatefulTransactionValidatorConfig,
StatelessTransactionValidatorConfig,
};
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<MempoolNodeConfig, papyrus_config::ConfigError> {
let config_file = File::open(Path::new(TEST_FILES_FOLDER).join(file_name)).unwrap();
load_and_process_config::<MempoolNodeConfig>(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 },
Expand All @@ -44,16 +30,7 @@ fn test_valid_config() {
},
rpc_state_reader_config: RpcStateReaderConfig::default(),
};
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.
Expand Down
82 changes: 0 additions & 82 deletions crates/mempool_node/src/test_files/mempool_node_config.json

This file was deleted.

0 comments on commit 405a4cd

Please sign in to comment.