Validate that the node home directory exists and contains all required components Checks for: - Home directory exists and is accessible - Required subdirectories (fendermint, cometbft) - Required configuration files - Logs directory is writable - Genesis files exist
(home: &Path)
| 85 | /// - Logs directory is writable |
| 86 | /// - Genesis files exist |
| 87 | async fn validate_node_home(home: &Path) -> Result<()> { |
| 88 | info!("Validating node home directory structure"); |
| 89 | |
| 90 | // Check home directory exists and is accessible |
| 91 | if !home.exists() { |
| 92 | bail!("Node home directory does not exist: {}", home.display()); |
| 93 | } |
| 94 | |
| 95 | if !home.is_dir() { |
| 96 | bail!("Node home path is not a directory: {}", home.display()); |
| 97 | } |
| 98 | |
| 99 | // Check for required subdirectories |
| 100 | let fendermint_dir = home.join("fendermint"); |
| 101 | let cometbft_dir = home.join("cometbft"); |
| 102 | |
| 103 | if !fendermint_dir.exists() { |
| 104 | bail!( |
| 105 | "Fendermint directory not found - run 'ipc-cli node init' first: {}", |
| 106 | fendermint_dir.display() |
| 107 | ); |
| 108 | } |
| 109 | |
| 110 | if !cometbft_dir.exists() { |
| 111 | bail!( |
| 112 | "CometBFT directory not found - run 'ipc-cli node init' first: {}", |
| 113 | cometbft_dir.display() |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | // Validate required configuration files exist |
| 118 | validate_required_config_files(&fendermint_dir, &cometbft_dir).await?; |
| 119 | |
| 120 | // Validate required data files exist |
| 121 | validate_required_data_files(&fendermint_dir, &cometbft_dir).await?; |
| 122 | |
| 123 | // Test that we can write to logs directory |
| 124 | validate_logs_directory_writable(home).await?; |
| 125 | |
| 126 | info!("Node home directory validation completed successfully"); |
| 127 | Ok(()) |
| 128 | } |
| 129 | |
| 130 | /// Validate that all required configuration files are present |
| 131 | async fn validate_required_config_files(fendermint_dir: &Path, cometbft_dir: &Path) -> Result<()> { |
no test coverage detected