2
2
3
3
mod common;
4
4
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 } ;
6
6
use lightning:: ln:: msgs:: LightningError ;
7
7
use lightning:: ln:: peer_handler:: CustomMessageHandler ;
8
8
use lightning:: util:: hash_tables:: HashSet ;
@@ -11,7 +11,7 @@ use lightning_liquidity::lsps5::event::{LSPS5ClientEvent, LSPS5ServiceEvent};
11
11
use lightning_liquidity:: lsps5:: msgs:: {
12
12
LSPS5AppName , LSPS5Error , LSPS5WebhookUrl , WebhookNotification , WebhookNotificationMethod ,
13
13
} ;
14
- use lightning_liquidity:: lsps5:: service:: { LSPS5ServiceConfig , TimeProvider } ;
14
+ use lightning_liquidity:: lsps5:: service:: TimeProvider ;
15
15
use lightning_liquidity:: lsps5:: service:: {
16
16
MIN_WEBHOOK_RETENTION_DAYS , PRUNE_STALE_WEBHOOKS_INTERVAL_DAYS ,
17
17
} ;
@@ -103,7 +103,6 @@ fn webhook_registration_flow() {
103
103
} ,
104
104
_ => panic ! ( "Expected SendWebhookNotifications event" ) ,
105
105
}
106
-
107
106
let set_webhook_response = get_lsps_message ! ( service_node, client_node_id) ;
108
107
109
108
client_node
@@ -123,7 +122,7 @@ fn webhook_registration_flow() {
123
122
request_id : req_id,
124
123
} ) => {
125
124
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 ) ;
127
126
assert_eq ! ( no_change, false ) ;
128
127
assert_eq ! ( lsp, service_node_id) ;
129
128
assert_eq ! ( an, app_name. clone( ) ) ;
@@ -154,7 +153,7 @@ fn webhook_registration_flow() {
154
153
} ) => {
155
154
assert_eq ! ( app_names, vec![ app_name. clone( ) ] ) ;
156
155
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 ) ;
158
157
assert_eq ! ( req_id, list_request_id) ;
159
158
} ,
160
159
_ => panic ! ( "Unexpected event" ) ,
@@ -177,7 +176,7 @@ fn webhook_registration_flow() {
177
176
} ) => {
178
177
assert_eq ! ( lsp, service_node_id) ;
179
178
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 ) ;
181
180
assert_eq ! ( request_id, list_request_id) ;
182
181
} ,
183
182
_ => panic ! ( "Unexpected event" ) ,
@@ -352,8 +351,7 @@ fn webhook_error_handling_test() {
352
351
// TEST 5: Too many webhooks - register the max number and then try one more
353
352
let valid_app_name_base = "Valid App" ;
354
353
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 {
357
355
let app_name = format ! ( "{} {}" , valid_app_name_base, i) ;
358
356
let _ = client_handler
359
357
. set_webhook ( service_node_id, app_name, valid_url. to_string ( ) )
@@ -369,11 +367,7 @@ fn webhook_error_handling_test() {
369
367
}
370
368
371
369
// 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 ) ;
377
371
let one_too_many = LSPS5AppName :: from_string ( raw_one_too_many. to_string ( ) ) . unwrap ( ) ;
378
372
let _ = client_handler
379
373
. set_webhook ( service_node_id, raw_one_too_many. clone ( ) , valid_url. to_string ( ) )
@@ -396,7 +390,7 @@ fn webhook_error_handling_test() {
396
390
} ) => {
397
391
let error_to_check = LSPS5Error :: TooManyWebhooks ( format ! (
398
392
"Maximum of {} webhooks allowed per client" ,
399
- LSPS5ServiceConfig :: default ( ) . max_webhooks_per_client
393
+ DEFAULT_MAX_WEBHOOKS_PER_CLIENT
400
394
) ) ;
401
395
assert_eq ! ( error, error_to_check) ;
402
396
assert_eq ! ( app_name, one_too_many) ;
0 commit comments