@@ -6,7 +6,6 @@ use std::sync::Arc;
66use std:: time:: Duration ;
77
88use anyhow:: { Context , Result , anyhow} ;
9- use clap:: Parser ;
109use hotfix:: config:: Config ;
1110use hotfix:: field_types:: Timestamp ;
1211use hotfix:: initiator:: Initiator ;
@@ -19,28 +18,21 @@ use tracing_subscriber::EnvFilter;
1918use crate :: application:: TestApplication ;
2019use crate :: messages:: { ExecReportSummary , NewOrderSingle , OutboundMsg } ;
2120
21+ const CONFIG_PATH : & str = "examples/custom-fields/config/test-config.toml" ;
2222const LOGON_TIMEOUT : Duration = Duration :: from_secs ( 10 ) ;
2323const FILL_TIMEOUT : Duration = Duration :: from_secs ( 10 ) ;
2424const STRATEGY_ID : i32 = 42 ;
2525const CL_ORD_ID : & str = "demo-1" ;
2626
27- #[ derive( Parser , Debug ) ]
28- #[ command( author, version, about) ]
29- struct Args {
30- #[ arg( short, long) ]
31- config : String ,
32- }
33-
3427#[ tokio:: main]
3528async fn main ( ) -> Result < ( ) > {
36- let args = Args :: parse ( ) ;
37-
3829 tracing_subscriber:: fmt ( )
39- . with_env_filter ( EnvFilter :: try_from_default_env ( ) . unwrap_or_else ( |_| EnvFilter :: new ( "info" ) ) )
30+ . with_env_filter (
31+ EnvFilter :: try_from_default_env ( ) . unwrap_or_else ( |_| EnvFilter :: new ( "info" ) ) ,
32+ )
4033 . init ( ) ;
4134
42- let mut config = Config :: load_from_path ( & args. config )
43- . context ( "failed to load config" ) ?;
35+ let mut config = Config :: load_from_path ( CONFIG_PATH ) . context ( "failed to load config" ) ?;
4436 let session_config = config
4537 . sessions
4638 . pop ( )
@@ -54,13 +46,10 @@ async fn main() -> Result<()> {
5446 exec_tx,
5547 } ;
5648
57- let initiator: Initiator < OutboundMsg > = Initiator :: start (
58- session_config,
59- app,
60- InMemoryMessageStore :: default ( ) ,
61- )
62- . await
63- . context ( "failed to start initiator" ) ?;
49+ let initiator: Initiator < OutboundMsg > =
50+ Initiator :: start ( session_config, app, InMemoryMessageStore :: default ( ) )
51+ . await
52+ . context ( "failed to start initiator" ) ?;
6453
6554 info ! ( "waiting for logon (up to {:?})" , LOGON_TIMEOUT ) ;
6655 timeout ( LOGON_TIMEOUT , logon_signal. notified ( ) )
@@ -75,9 +64,7 @@ async fn main() -> Result<()> {
7564 transact_time : Timestamp :: utc_now ( ) ,
7665 client_strategy_id : STRATEGY_ID ,
7766 } ;
78- info ! (
79- "sending NewOrderSingle ClOrdID={CL_ORD_ID} ClientStrategyId={STRATEGY_ID}"
80- ) ;
67+ info ! ( "sending NewOrderSingle ClOrdID={CL_ORD_ID} ClientStrategyId={STRATEGY_ID}" ) ;
8168 initiator
8269 . send ( OutboundMsg :: NewOrderSingle ( order) )
8370 . await
@@ -99,27 +86,33 @@ async fn wait_for_fill(exec_rx: &mut mpsc::UnboundedReceiver<ExecReportSummary>)
9986 loop {
10087 let remaining = deadline. saturating_duration_since ( tokio:: time:: Instant :: now ( ) ) ;
10188 if remaining. is_zero ( ) {
102- return Err ( anyhow ! ( "did not receive a Filled ExecutionReport within {FILL_TIMEOUT:?}" ) ) ;
89+ return Err ( anyhow ! (
90+ "did not receive a Filled ExecutionReport within {FILL_TIMEOUT:?}"
91+ ) ) ;
10392 }
10493
10594 let summary = match timeout ( remaining, exec_rx. recv ( ) ) . await {
10695 Ok ( Some ( s) ) => s,
10796 Ok ( None ) => return Err ( anyhow ! ( "execution-report channel closed unexpectedly" ) ) ,
108- Err ( _) => return Err ( anyhow ! ( "did not receive a Filled ExecutionReport within {FILL_TIMEOUT:?}" ) ) ,
97+ Err ( _) => {
98+ return Err ( anyhow ! (
99+ "did not receive a Filled ExecutionReport within {FILL_TIMEOUT:?}"
100+ ) ) ;
101+ }
109102 } ;
110103
111104 info ! (
112105 "received ExecutionReport ClOrdID={} OrdStatus={:?} ClientStrategyId={:?}" ,
113106 summary. cl_ord_id, summary. ord_status, summary. client_strategy_id,
114107 ) ;
115108
116- let echoed = summary
117- . client_strategy_id
118- . ok_or_else ( || anyhow ! (
109+ let echoed = summary. client_strategy_id . ok_or_else ( || {
110+ anyhow ! (
119111 "ExecutionReport for ClOrdID={} did not echo ClientStrategyId — \
120112 the acceptor likely doesn't know about tag 6001",
121113 summary. cl_ord_id,
122- ) ) ?;
114+ )
115+ } ) ?;
123116
124117 if echoed != STRATEGY_ID {
125118 return Err ( anyhow ! (
0 commit comments