Skip to content

Commit

Permalink
debug unstable payment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Feb 28, 2025
1 parent 0cda250 commit fde5c80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
27 changes: 1 addition & 26 deletions src/fiber/tests/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,40 +1715,15 @@ async fn test_send_payment_with_max_nodes() {
let amounts = vec![(100000000000, 100000000000); nodes_num - 1];
let (nodes, channels) =
create_n_nodes_with_established_channel(&amounts, nodes_num, true).await;
let source_node = &nodes[0];
let target_pubkey = nodes[last].pubkey;

let sender_local = nodes[0].get_local_balance_from_channel(channels[0]);
let receiver_local = nodes[last].get_local_balance_from_channel(channels[last - 1]);

// sleep for seconds to make sure the channel is established
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
tokio::time::sleep(tokio::time::Duration::from_millis(800)).await;
let sent_amount = 1000000 + 5;

let message = |rpc_reply| -> NetworkActorMessage {
NetworkActorMessage::Command(NetworkActorCommand::SendPayment(
SendPaymentCommand {
target_pubkey: Some(target_pubkey),
amount: Some(sent_amount),
payment_hash: None,
final_tlc_expiry_delta: None,
invoice: None,
timeout: None,
max_fee_amount: None,
tlc_expiry_limit: None,
max_parts: None,
keysend: Some(true),
udt_type_script: None,
allow_self_payment: false,
hop_hints: None,
dry_run: true,
},
rpc_reply,
))
};
let res = call!(source_node.network_actor, message).expect("node_a alive");
assert!(res.is_ok());

let message = |rpc_reply| -> NetworkActorMessage {
NetworkActorMessage::Command(NetworkActorCommand::SendPayment(
SendPaymentCommand {
Expand Down
19 changes: 18 additions & 1 deletion src/fiber/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,24 @@ pub(crate) async fn create_n_nodes_and_channels_with_index_amounts(
}
}
// sleep for a while to make sure network graph is updated
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
for _ in 0..50 {
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
if nodes[0].get_network_graph_channels().await.len() >= amounts.len() {
break;
}
}
let graph_channels = nodes[0].get_network_graph_channels().await;
if graph_channels.len() < amounts.len() {
use tracing::error;
error!(
"failed to sync all graph channels, expect {} got {}",
amounts.len(),
graph_channels.len()
);
for (i, chan) in graph_channels.into_iter().enumerate() {
error!(">>> channel {}: {:?}", i, chan);
}
}
(nodes, channels)
}

Expand Down

0 comments on commit fde5c80

Please sign in to comment.