Skip to content

Commit 7b465f9

Browse files
committed
Add test for refund creation with insufficient liquidity
Adds the `fails_creating_refund_with_insufficient_liquidity` test to verify that the `create_refund_builder` method correctly handles cases where there is insufficient channel liquidity. The test verifies that the method returns the `Bolt12RequestError::InsufficientLiquidity` error when the refund amount exceeds the available liquidity.
1 parent b22a843 commit 7b465f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,4 +2369,26 @@ fn fails_paying_offer_with_insufficient_liquidity() {
23692369
assert_eq!(e, Bolt12RequestError::InsufficientLiquidity);
23702370
}
23712371
}
2372+
}
2373+
2374+
#[test]
2375+
fn fails_creating_refund_with_insufficient_liquidity() {
2376+
let chanmon_cfgs = create_chanmon_cfgs(2);
2377+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
2378+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
2379+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2380+
2381+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
2382+
2383+
let bob = &nodes[1];
2384+
2385+
let absolute_expiry = Duration::from_secs(u64::MAX);
2386+
let payment_id = PaymentId([1; 32]);
2387+
let refund = bob.node
2388+
.create_refund_builder(950_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None);
2389+
2390+
match refund {
2391+
Ok(_) => panic!("Expected error with insufficient liquidity."),
2392+
Err(e) => assert_eq!(e, Bolt12RequestError::InsufficientLiquidity),
2393+
}
23722394
}

0 commit comments

Comments
 (0)