22
33mod common;
44
5- use common:: { get_client_and_service, get_lsps_message} ;
5+ use common:: { get_client_and_service, get_lsps_message, DEFAULT_MAX_WEBHOOKS_PER_CLIENT } ;
66use lightning:: ln:: msgs:: LightningError ;
77use lightning:: ln:: peer_handler:: CustomMessageHandler ;
88use lightning:: util:: hash_tables:: HashSet ;
@@ -11,7 +11,7 @@ use lightning_liquidity::lsps5::event::{LSPS5ClientEvent, LSPS5ServiceEvent};
1111use lightning_liquidity:: lsps5:: msgs:: {
1212 LSPS5AppName , LSPS5Error , LSPS5WebhookUrl , WebhookNotification , WebhookNotificationMethod ,
1313} ;
14- use lightning_liquidity:: lsps5:: service:: { LSPS5ServiceConfig , TimeProvider } ;
14+ use lightning_liquidity:: lsps5:: service:: TimeProvider ;
1515use lightning_liquidity:: lsps5:: service:: {
1616 MIN_WEBHOOK_RETENTION_DAYS , PRUNE_STALE_WEBHOOKS_INTERVAL_DAYS ,
1717} ;
@@ -103,7 +103,6 @@ fn webhook_registration_flow() {
103103 } ,
104104 _ => panic ! ( "Expected SendWebhookNotifications event" ) ,
105105 }
106-
107106 let set_webhook_response = get_lsps_message ! ( service_node, client_node_id) ;
108107
109108 client_node
@@ -123,7 +122,7 @@ fn webhook_registration_flow() {
123122 request_id : req_id,
124123 } ) => {
125124 assert_eq ! ( num_webhooks, 1 ) ;
126- assert_eq ! ( max_webhooks, LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client ) ;
125+ assert_eq ! ( max_webhooks, DEFAULT_MAX_WEBHOOKS_PER_CLIENT ) ;
127126 assert_eq ! ( no_change, false ) ;
128127 assert_eq ! ( lsp, service_node_id) ;
129128 assert_eq ! ( an, app_name. clone( ) ) ;
@@ -154,7 +153,7 @@ fn webhook_registration_flow() {
154153 } ) => {
155154 assert_eq ! ( app_names, vec![ app_name. clone( ) ] ) ;
156155 assert_eq ! ( counterparty_node_id, client_node_id) ;
157- assert_eq ! ( max_webhooks, LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client ) ;
156+ assert_eq ! ( max_webhooks, DEFAULT_MAX_WEBHOOKS_PER_CLIENT ) ;
158157 assert_eq ! ( req_id, list_request_id) ;
159158 } ,
160159 _ => panic ! ( "Unexpected event" ) ,
@@ -177,7 +176,7 @@ fn webhook_registration_flow() {
177176 } ) => {
178177 assert_eq ! ( lsp, service_node_id) ;
179178 assert_eq ! ( app_names, vec![ app_name. clone( ) ] ) ;
180- assert_eq ! ( max_webhooks, LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client ) ;
179+ assert_eq ! ( max_webhooks, DEFAULT_MAX_WEBHOOKS_PER_CLIENT ) ;
181180 assert_eq ! ( request_id, list_request_id) ;
182181 } ,
183182 _ => panic ! ( "Unexpected event" ) ,
@@ -352,8 +351,7 @@ fn webhook_error_handling_test() {
352351 // TEST 5: Too many webhooks - register the max number and then try one more
353352 let valid_app_name_base = "Valid App" ;
354353 let valid_url = "https://example.org/webhook" ;
355-
356- for i in 0 ..LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client {
354+ for i in 0 ..DEFAULT_MAX_WEBHOOKS_PER_CLIENT {
357355 let app_name = format ! ( "{} {}" , valid_app_name_base, i) ;
358356 let _ = client_handler
359357 . set_webhook ( service_node_id, app_name, valid_url. to_string ( ) )
@@ -369,11 +367,7 @@ fn webhook_error_handling_test() {
369367 }
370368
371369 // Now try to add one more webhook - should fail with too many webhooks error
372- let raw_one_too_many = format ! (
373- "{} {}" ,
374- valid_app_name_base,
375- LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client
376- ) ;
370+ let raw_one_too_many = format ! ( "{} {}" , valid_app_name_base, DEFAULT_MAX_WEBHOOKS_PER_CLIENT ) ;
377371 let one_too_many = LSPS5AppName :: from_string ( raw_one_too_many. to_string ( ) ) . unwrap ( ) ;
378372 let _ = client_handler
379373 . set_webhook ( service_node_id, raw_one_too_many. clone ( ) , valid_url. to_string ( ) )
@@ -396,7 +390,7 @@ fn webhook_error_handling_test() {
396390 } ) => {
397391 let error_to_check = LSPS5Error :: TooManyWebhooks ( format ! (
398392 "Maximum of {} webhooks allowed per client" ,
399- LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client
393+ DEFAULT_MAX_WEBHOOKS_PER_CLIENT
400394 ) ) ;
401395 assert_eq ! ( error, error_to_check) ;
402396 assert_eq ! ( app_name, one_too_many) ;
0 commit comments