|
40 | 40 | //! Nodes without channels are disconnected and connected as needed to ensure that deterministic
|
41 | 41 | //! blinded paths are used.
|
42 | 42 |
|
| 43 | +use bitcoin::network::constants::Network; |
43 | 44 | use core::time::Duration;
|
44 | 45 | use crate::blinded_path::BlindedPath;
|
45 | 46 | use crate::events::{Event, MessageSendEventsProvider, PaymentPurpose};
|
@@ -732,6 +733,61 @@ fn fails_creating_refund_without_blinded_paths() {
|
732 | 733 | assert!(nodes[0].node.list_recent_payments().is_empty());
|
733 | 734 | }
|
734 | 735 |
|
| 736 | +/// Fails creating an invoice request when the offer contains an unsupported chain. |
| 737 | +#[test] |
| 738 | +fn fails_creating_invoice_request_for_unsupported_chain() { |
| 739 | + let chanmon_cfgs = create_chanmon_cfgs(2); |
| 740 | + let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); |
| 741 | + let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); |
| 742 | + let nodes = create_network(2, &node_cfgs, &node_chanmgrs); |
| 743 | + |
| 744 | + create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000); |
| 745 | + |
| 746 | + let alice = &nodes[0]; |
| 747 | + let bob = &nodes[1]; |
| 748 | + |
| 749 | + let offer = alice.node |
| 750 | + .create_offer_builder("coffee".to_string()).unwrap() |
| 751 | + .clear_chains() |
| 752 | + .chain(Network::Signet) |
| 753 | + .build().unwrap(); |
| 754 | + |
| 755 | + let payment_id = PaymentId([1; 32]); |
| 756 | + match bob.node.pay_for_offer(&offer, None, None, None, payment_id, Retry::Attempts(0), None) { |
| 757 | + Ok(_) => panic!("Expected error"), |
| 758 | + Err(e) => assert_eq!(e, Bolt12SemanticError::UnsupportedChain), |
| 759 | + } |
| 760 | +} |
| 761 | + |
| 762 | +/// Fails requesting a payment when the refund contains an unsupported chain. |
| 763 | +#[test] |
| 764 | +fn fails_sending_invoice_with_unsupported_chain_for_refund() { |
| 765 | + let chanmon_cfgs = create_chanmon_cfgs(2); |
| 766 | + let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); |
| 767 | + let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); |
| 768 | + let nodes = create_network(2, &node_cfgs, &node_chanmgrs); |
| 769 | + |
| 770 | + create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000); |
| 771 | + |
| 772 | + let alice = &nodes[0]; |
| 773 | + let bob = &nodes[1]; |
| 774 | + |
| 775 | + let absolute_expiry = Duration::from_secs(u64::MAX); |
| 776 | + let payment_id = PaymentId([1; 32]); |
| 777 | + let refund = bob.node |
| 778 | + .create_refund_builder( |
| 779 | + "refund".to_string(), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None |
| 780 | + ) |
| 781 | + .unwrap() |
| 782 | + .chain(Network::Signet) |
| 783 | + .build().unwrap(); |
| 784 | + |
| 785 | + match alice.node.request_refund_payment(&refund) { |
| 786 | + Ok(_) => panic!("Expected error"), |
| 787 | + Err(e) => assert_eq!(e, Bolt12SemanticError::UnsupportedChain), |
| 788 | + } |
| 789 | +} |
| 790 | + |
735 | 791 | /// Fails creating an invoice request when a blinded reply path cannot be created without exposing
|
736 | 792 | /// the node's id.
|
737 | 793 | #[test]
|
|
0 commit comments