@@ -2064,3 +2064,34 @@ fn fails_paying_invoice_more_than_once() {
2064
2064
let invoice_error = extract_invoice_error ( alice, & onion_message) ;
2065
2065
assert_eq ! ( invoice_error, InvoiceError :: from_string( "DuplicateInvoice" . to_string( ) ) ) ;
2066
2066
}
2067
+
2068
+ #[ test]
2069
+ fn test_insufficient_liquidity_for_bolt12_offer ( ) {
2070
+ let channel_mon_config = create_chanmon_cfgs ( 2 ) ;
2071
+ let node_config = create_node_cfgs ( 2 , & channel_mon_config) ;
2072
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_config, & [ None , None ] ) ;
2073
+ let nodes = create_network ( 2 , & node_config, & node_chanmgrs) ;
2074
+
2075
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
2076
+
2077
+ let ( alice, bob) = ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
2078
+ let alice_id = alice. node . get_our_node_id ( ) ;
2079
+
2080
+ let offer = alice. node
2081
+ . create_offer_builder ( None ) . unwrap ( )
2082
+ . clear_paths ( )
2083
+ . amount_msats ( 1_000_000_001 )
2084
+ . build ( ) . unwrap ( ) ;
2085
+ assert_eq ! ( offer. signing_pubkey( ) , Some ( alice_id) ) ;
2086
+ assert ! ( offer. paths( ) . is_empty( ) ) ;
2087
+
2088
+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
2089
+
2090
+ let result = bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) ;
2091
+ match result {
2092
+ Ok ( _) => panic ! ( "Expected error with insufficient liquidity." ) ,
2093
+ Err ( e) => {
2094
+ assert_eq ! ( e, Bolt12SemanticError :: InsufficientLiquidity ) ;
2095
+ }
2096
+ }
2097
+ }
0 commit comments