File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub use utils::*;
2626#[ derive( Debug , Deserialize , Serialize ) ]
2727pub struct CommitBoostConfig {
2828 pub chain : Chain ,
29+ #[ serde( default ) ]
2930 pub relays : Vec < RelayConfig > ,
3031 pub pbs : StaticPbsConfig ,
3132 #[ serde( flatten) ]
Original file line number Diff line number Diff line change @@ -229,6 +229,14 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
229229 let config = CommitBoostConfig :: from_env_path ( ) ?;
230230 config. validate ( ) . await ?;
231231
232+ // Make sure relays isn't empty - since the config is still technically valid if
233+ // there are no relays for things like Docker compose generation, this check
234+ // isn't in validate().
235+ ensure ! (
236+ !config. relays. is_empty( ) ,
237+ "At least one relay must be configured to run the PBS service"
238+ ) ;
239+
232240 // use endpoint from env if set, otherwise use default host and port
233241 let endpoint = if let Some ( endpoint) = load_optional_env_var ( PBS_ENDPOINT_ENV ) {
234242 endpoint. parse ( ) ?
Original file line number Diff line number Diff line change @@ -170,3 +170,15 @@ async fn test_validate_missing_rpc_url() -> Result<()> {
170170 . contains( "rpc_url is required if extra_validation_enabled is true" ) ) ;
171171 Ok ( ( ) )
172172}
173+
174+ #[ tokio:: test]
175+ async fn test_validate_config_with_no_relays ( ) -> Result < ( ) > {
176+ // Create a config with no relays
177+ let mut config = load_happy_config ( ) . await ?;
178+ config. relays . clear ( ) ;
179+
180+ // Make sure it validates correctly
181+ let result = config. validate ( ) . await ;
182+ assert ! ( result. is_ok( ) ) ;
183+ Ok ( ( ) )
184+ }
You can’t perform that action at this time.
0 commit comments