From 2b3bfc5f55937eb4b84e8119db37f92e87feebeb Mon Sep 17 00:00:00 2001 From: yukang Date: Mon, 27 Jan 2025 13:12:39 +0800 Subject: [PATCH] remove unneeded mut in testing code --- src/fiber/tests/channel.rs | 4 ++-- src/fiber/tests/payment.rs | 6 +++--- src/fiber/tests/test_utils.rs | 14 +++++--------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/fiber/tests/channel.rs b/src/fiber/tests/channel.rs index 9144f2d1..c8bca9cd 100644 --- a/src/fiber/tests/channel.rs +++ b/src/fiber/tests/channel.rs @@ -5070,7 +5070,7 @@ async fn test_send_payment_with_channel_balance_error() { let amounts = vec![(100000000000, 100000000000); nodes_num - 1]; let (nodes, channels) = create_n_nodes_with_established_channel(&amounts, nodes_num, true).await; - let [node_0, _node_1, mut node_2, node_3] = nodes.try_into().expect("4 nodes"); + let [node_0, _node_1, node_2, node_3] = nodes.try_into().expect("4 nodes"); let source_node = &node_0; let target_pubkey = node_3.pubkey.clone(); @@ -5758,7 +5758,7 @@ async fn test_send_payment_will_succeed_with_retry_in_middle_hops() { true, ) .await; - let [mut node_0, _node_1, mut node_2, node_3] = nodes.try_into().expect("4 nodes"); + let [mut node_0, _node_1, node_2, node_3] = nodes.try_into().expect("4 nodes"); let source_node = &mut node_0; let node_0_amount = source_node.get_local_balance_from_channel(channels[0]); let target_pubkey = node_3.pubkey.clone(); diff --git a/src/fiber/tests/payment.rs b/src/fiber/tests/payment.rs index d92c5917..e9a31701 100644 --- a/src/fiber/tests/payment.rs +++ b/src/fiber/tests/payment.rs @@ -1917,7 +1917,7 @@ async fn test_send_payment_middle_hop_update_fee_send_payment_failed() { true, ) .await; - let [node_0, _node_1, mut node_2, node_3] = nodes.try_into().expect("4 nodes"); + let [node_0, _node_1, node_2, node_3] = nodes.try_into().expect("4 nodes"); // node_2 update fee rate to a higher one, so the payment will fail let res = node_0 @@ -1947,7 +1947,7 @@ async fn test_send_payment_middle_hop_update_fee_multiple_payments() { // https://github.com/nervosnetwork/fiber/issues/480 init_tracing(); let _span = tracing::info_span!("node", node = "test").entered(); - let (mut nodes, channels) = create_n_nodes_with_index_and_amounts_with_established_channel( + let (nodes, channels) = create_n_nodes_with_index_and_amounts_with_established_channel( &[ ((0, 1), (HUGE_CKB_AMOUNT, HUGE_CKB_AMOUNT)), ((1, 2), (HUGE_CKB_AMOUNT, HUGE_CKB_AMOUNT)), @@ -2015,7 +2015,7 @@ async fn test_send_payment_middle_hop_update_fee_should_recovery() { // in the end, all the payments should success init_tracing(); let _span = tracing::info_span!("node", node = "test").entered(); - let (mut nodes, channels) = create_n_nodes_with_index_and_amounts_with_established_channel( + let (nodes, channels) = create_n_nodes_with_index_and_amounts_with_established_channel( &[ ((0, 1), (HUGE_CKB_AMOUNT, HUGE_CKB_AMOUNT)), ((1, 2), (HUGE_CKB_AMOUNT, HUGE_CKB_AMOUNT)), diff --git a/src/fiber/tests/test_utils.rs b/src/fiber/tests/test_utils.rs index 1ec6403b..a3691a44 100644 --- a/src/fiber/tests/test_utils.rs +++ b/src/fiber/tests/test_utils.rs @@ -710,7 +710,7 @@ impl NetworkNode { } pub async fn update_channel_actor_state( - &mut self, + &self, state: ChannelActorState, reload_params: Option, ) { @@ -728,7 +728,7 @@ impl NetworkNode { } pub async fn update_channel_local_balance( - &mut self, + &self, channel_id: Hash256, new_to_local_amount: u128, ) { @@ -739,7 +739,7 @@ impl NetworkNode { } pub async fn update_channel_remote_balance( - &mut self, + &self, channel_id: Hash256, new_to_remote_amount: u128, ) { @@ -756,7 +756,7 @@ impl NetworkNode { .await; } - pub async fn disable_channel_stealthy(&mut self, channel_id: Hash256) { + pub async fn disable_channel_stealthy(&self, channel_id: Hash256) { let mut channel_actor_state = self.get_channel_actor_state(channel_id); channel_actor_state.local_tlc_info.enabled = false; self.update_channel_actor_state( @@ -768,11 +768,7 @@ impl NetworkNode { .await; } - pub async fn update_channel_with_command( - &mut self, - channel_id: Hash256, - command: UpdateCommand, - ) { + pub async fn update_channel_with_command(&self, channel_id: Hash256, command: UpdateCommand) { let message = |rpc_reply| -> NetworkActorMessage { NetworkActorMessage::Command(NetworkActorCommand::ControlFiberChannel( ChannelCommandWithId {