Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/hotfix/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- possibility to disalbe original sending time(tag 122) for admin messages

## [0.11.0](https://github.com/Validus-Risk-Management/hotfix/compare/hotfix-v0.10.0...hotfix-v0.11.0) - 2026-03-25

### Added
Expand Down
109 changes: 109 additions & 0 deletions crates/hotfix/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,63 @@ pub struct SessionConfig {

/// The schedule configuration for the session
pub schedule: Option<ScheduleConfig>,

/// The validation configuration for the session
#[serde(default)]
pub verification: VerificationConfig,
}

#[derive(Clone, Debug, Deserialize)]
/// The configuration of validation rules.
pub struct VerificationConfig {
/// Specifies whether we should check the original sending time for admin messages.
#[serde(default = "default_true")]
pub check_orig_sending_time_for_admin: bool,
}

impl VerificationConfig {
pub fn builder() -> VerificationConfigBuilder {
VerificationConfigBuilder::default()
}
}

impl Default for VerificationConfig {
fn default() -> Self {
VerificationConfigBuilder::default().build()
}
}

pub struct VerificationConfigBuilder {
check_orig_sending_time_for_admin: bool,
}

impl Default for VerificationConfigBuilder {
fn default() -> Self {
Self {
check_orig_sending_time_for_admin: true,
}
}
}

impl VerificationConfigBuilder {
pub fn new() -> Self {
Self::default()
}

pub fn check_orig_sending_time_for_admin(mut self, value: bool) -> Self {
self.check_orig_sending_time_for_admin = value;
self
}

pub fn build(self) -> VerificationConfig {
VerificationConfig {
check_orig_sending_time_for_admin: self.check_orig_sending_time_for_admin,
}
}
}

fn default_true() -> bool {
true
}

/// Errors that may occur when loading configuration.
Expand Down Expand Up @@ -170,6 +227,11 @@ reset_on_logon = false
assert_eq!(session_config.tls_config, Some(expected_tls_config));
assert_eq!(session_config.reconnect_interval, 30);
assert_eq!(session_config.logon_timeout, 10);
assert!(
session_config
.verification
.check_orig_sending_time_for_admin
);
}

#[test]
Expand Down Expand Up @@ -439,6 +501,53 @@ end_day = "Friday"
assert_eq!(session_config.reconnect_interval, 15);
}

#[test]
fn test_verification_config_defaults_when_omitted() {
let config_contents = r#"
[[sessions]]
begin_string = "FIX.4.4"
sender_comp_id = "send-comp-id"
target_comp_id = "target-comp-id"
connection_port = 443
connection_host = "127.0.0.1"
heartbeat_interval = 30
"#;

let config: Config = toml::from_str(config_contents).unwrap();
let session_config = config.sessions.first().unwrap();

assert!(
session_config
.verification
.check_orig_sending_time_for_admin
);
}

#[test]
fn test_verification_config_can_disable_admin_orig_sending_time_check() {
let config_contents = r#"
[[sessions]]
begin_string = "FIX.4.4"
sender_comp_id = "send-comp-id"
target_comp_id = "target-comp-id"
connection_port = 443
connection_host = "127.0.0.1"
heartbeat_interval = 30

[sessions.verification]
check_orig_sending_time_for_admin = false
"#;

let config: Config = toml::from_str(config_contents).unwrap();
let session_config = config.sessions.first().unwrap();

assert!(
!session_config
.verification
.check_orig_sending_time_for_admin
);
}

#[test]
fn test_load_from_path_success() {
let config_contents = r#"
Expand Down
2 changes: 2 additions & 0 deletions crates/hotfix/src/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async fn establish_connection<Outbound: OutboundMessage>(
mod tests {
use super::*;
use crate::application::{Application, InboundDecision, OutboundDecision};
use crate::config::VerificationConfig;
use crate::message::generate_message;
use crate::message::logon::{Logon, ResetSeqNumConfig};
use crate::message::logout::Logout;
Expand Down Expand Up @@ -299,6 +300,7 @@ mod tests {
reconnect_interval: 1, // Short for tests
reset_on_logon: false,
schedule: None,
verification: VerificationConfig::default(),
}
}

Expand Down
Loading
Loading