Skip to content

Commit

Permalink
Update graph on channel ready
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Jan 10, 2025
1 parent 510d491 commit 305bdee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5688,6 +5688,15 @@ impl ChannelActorState {
),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);
if let Ok(channel_info) = (&*self).try_into() {
network
.send_message(NetworkActorMessage::new_event(
NetworkActorEvent::OwnedChannelUpdateEvent(
super::graph::OwnedChannelUpdateEvent::Up(channel_info),
),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);
}
}

fn append_remote_commitment_point(&mut self, commitment_point: Pubkey) {
Expand Down
19 changes: 13 additions & 6 deletions src/fiber/tests/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,20 @@ async fn test_create_public_channel() {
.await;
}

#[tokio::test]
async fn test_public_channel_saved_to_the_owner_graph() {
init_tracing();

async fn do_test_owned_channel_saved_to_the_owner_graph(public: bool) {
let node1_funding_amount = 100000000000;
let node2_funding_amount = 6200000000;

let (mut node1, mut node2, _new_channel_id, _) =
NetworkNode::new_2_nodes_with_established_channel(
node1_funding_amount,
node2_funding_amount,
true,
public,
)
.await;

// Wait for the channel announcement to be broadcasted
tokio::time::sleep(tokio::time::Duration::from_millis(2000)).await;
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;

let node1_id = node1.peer_id.clone();
node1.stop().await;
Expand Down Expand Up @@ -269,6 +266,16 @@ async fn test_public_channel_saved_to_the_owner_graph() {
}
}

#[tokio::test]
async fn test_owned_public_channel_saved_to_the_owner_graph() {
do_test_owned_channel_saved_to_the_owner_graph(true).await;
}

#[tokio::test]
async fn test_owned_private_channel_saved_to_the_owner_graph() {
do_test_owned_channel_saved_to_the_owner_graph(false).await;
}

#[tokio::test]
async fn test_public_channel_saved_to_the_other_nodes_graph() {
init_tracing();
Expand Down

0 comments on commit 305bdee

Please sign in to comment.