@@ -1130,6 +1130,58 @@ fn simple_bolt12_send_receive() {
11301130 assert_eq ! ( node_a_payments. first( ) . unwrap( ) . amount_msat, Some ( overpaid_amount) ) ;
11311131}
11321132
1133+ #[ test]
1134+ fn static_invoice_server ( ) {
1135+ let ( bitcoind, electrsd) = setup_bitcoind_and_electrsd ( ) ;
1136+ let chain_source = TestChainSource :: Esplora ( & electrsd) ;
1137+ let ( node_a, node_b) = setup_two_nodes ( & chain_source, false , true , false ) ;
1138+
1139+ let address_a = node_a. onchain_payment ( ) . new_address ( ) . unwrap ( ) ;
1140+ let premine_amount_sat = 5_000_000 ;
1141+ premine_and_distribute_funds (
1142+ & bitcoind. client ,
1143+ & electrsd. client ,
1144+ vec ! [ address_a] ,
1145+ Amount :: from_sat ( premine_amount_sat) ,
1146+ ) ;
1147+
1148+ node_a. sync_wallets ( ) . unwrap ( ) ;
1149+ open_channel ( & node_a, & node_b, 4_000_000 , true , & electrsd) ;
1150+
1151+ generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
1152+
1153+ node_a. sync_wallets ( ) . unwrap ( ) ;
1154+ node_b. sync_wallets ( ) . unwrap ( ) ;
1155+
1156+ expect_channel_ready_event ! ( node_a, node_b. node_id( ) ) ;
1157+ expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
1158+
1159+ // Sleep until we broadcasted a node announcement.
1160+ while node_b. status ( ) . latest_node_announcement_broadcast_timestamp . is_none ( ) {
1161+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
1162+ }
1163+
1164+ // Sleep one more sec to make sure the node announcement propagates.
1165+ std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
1166+
1167+ let recipient_id = vec ! [ 1 , 2 , 3 ] ;
1168+ let blinded_paths = node_a. blinded_paths_for_async_recipient ( recipient_id, None ) . unwrap ( ) ;
1169+ node_b. set_paths_to_static_invoice_server ( blinded_paths) . unwrap ( ) ;
1170+
1171+ // Sleep to get the cache filled.
1172+ std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
1173+
1174+ let mut iter = 0 ;
1175+ while node_b. bolt12_payment ( ) . get_async_receive_offer ( ) . is_err ( ) {
1176+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) ;
1177+
1178+ iter += 1 ;
1179+ if iter > 10 {
1180+ assert ! ( false , "Failed to fetch static invoice offer" ) ;
1181+ }
1182+ }
1183+ }
1184+
11331185#[ test]
11341186fn test_node_announcement_propagation ( ) {
11351187 let ( bitcoind, electrsd) = setup_bitcoind_and_electrsd ( ) ;
0 commit comments