Skip to content

Commit 2b3dd97

Browse files
committed
Add simple test for send_probe_payment
1 parent 7525c85 commit 2b3dd97

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7725,6 +7725,38 @@ mod tests {
77257725
// Check that using the original payment hash succeeds.
77267726
assert!(inbound_payment::verify(payment_hash, &payment_data, nodes[0].node.highest_seen_timestamp.load(Ordering::Acquire) as u64, &nodes[0].node.inbound_payment_key, &nodes[0].logger).is_ok());
77277727
}
7728+
7729+
#[test]
7730+
fn sent_probe_is_probe_of_sending_node() {
7731+
let chanmon_cfgs = create_chanmon_cfgs(3);
7732+
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
7733+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None, None]);
7734+
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
7735+
7736+
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
7737+
create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
7738+
7739+
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], 100000);
7740+
7741+
match nodes[0].node.send_probe_payment(&route) {
7742+
Ok((payment_hash, payment_id)) => {
7743+
assert!(nodes[0].node.payment_is_probe(payment_hash, payment_id));
7744+
assert!(!nodes[1].node.payment_is_probe(payment_hash, payment_id));
7745+
assert!(!nodes[2].node.payment_is_probe(payment_hash, payment_id));
7746+
},
7747+
_ => panic!(),
7748+
}
7749+
7750+
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
7751+
assert_eq!(msg_events.len(), 1);
7752+
match msg_events.pop().unwrap() {
7753+
MessageSendEvent::UpdateHTLCs { node_id, .. } => {
7754+
assert_eq!(node_id, nodes[1].node.get_our_node_id());
7755+
},
7756+
_ => panic!(),
7757+
}
7758+
check_added_monitors!(nodes[0], 1);
7759+
}
77287760
}
77297761

77307762
#[cfg(all(any(test, feature = "_test_utils"), feature = "_bench_unstable"))]

0 commit comments

Comments
 (0)