kora_lib/bundle/jito/
config.rs1use serde::{Deserialize, Serialize};
2use utoipa::ToSchema;
3
4use crate::bundle::jito::constant::JITO_DEFAULT_BLOCK_ENGINE_URL;
5
6#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
8pub struct JitoConfig {
9 #[serde(default = "default_jito_block_engine_url")]
11 pub block_engine_url: String,
12}
13
14fn default_jito_block_engine_url() -> String {
15 JITO_DEFAULT_BLOCK_ENGINE_URL.to_string()
16}
17
18impl Default for JitoConfig {
19 fn default() -> Self {
20 Self { block_engine_url: JITO_DEFAULT_BLOCK_ENGINE_URL.to_string() }
21 }
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 #[test]
29 fn test_jito_config_default() {
30 let config = JitoConfig::default();
31 assert_eq!(config.block_engine_url, JITO_DEFAULT_BLOCK_ENGINE_URL);
32 }
33
34 #[test]
35 fn test_jito_config_serde() {
36 let toml = r#"
37 block_engine_url = "https://custom.jito.wtf"
38 "#;
39 let config: JitoConfig = toml::from_str(toml).unwrap();
40 assert_eq!(config.block_engine_url, "https://custom.jito.wtf");
41 }
42
43 #[test]
44 fn test_jito_config_empty_uses_defaults() {
45 let toml = "";
46 let config: JitoConfig = toml::from_str(toml).unwrap();
47 assert_eq!(config.block_engine_url, JITO_DEFAULT_BLOCK_ENGINE_URL);
48 }
49
50 #[test]
51 fn test_jito_config_mock_url() {
52 use crate::bundle::jito::constant::JITO_MOCK_BLOCK_ENGINE_URL;
53
54 let toml = r#"block_engine_url = "mock""#;
55 let config: JitoConfig = toml::from_str(toml).unwrap();
56 assert_eq!(config.block_engine_url, JITO_MOCK_BLOCK_ENGINE_URL);
57 assert_eq!(config.block_engine_url, "mock");
58 }
59}