Skip to content

Commit 7825d01

Browse files
committed
feat: log out endpoint in case of failed connection attempt
1 parent f4ddee9 commit 7825d01

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

crates/tap-agent/src/agent/sender_account.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,12 @@ impl Actor for SenderAccount {
608608
.expect("Failed to create an endpoint for the sender aggregator")
609609
.connect_timeout(config.rav_request_timeout);
610610

611-
let sender_aggregator = TapAggregatorClient::connect(endpoint)
611+
let sender_aggregator = TapAggregatorClient::connect(endpoint.clone())
612612
.await
613-
.expect("Failed to connect to the TapAggregator endpoint")
613+
.expect(&format!(
614+
"Failed to connect to the TapAggregator endpoint '{}'",
615+
endpoint.uri()
616+
))
614617
.send_compressed(tonic::codec::CompressionEncoding::Zstd);
615618

616619
let state = State {
@@ -1040,9 +1043,7 @@ impl SenderAccount {
10401043
#[cfg(test)]
10411044
pub mod tests {
10421045
use std::{
1043-
collections::{HashMap, HashSet},
1044-
sync::{atomic::AtomicU32, Arc},
1045-
time::{Duration, SystemTime, UNIX_EPOCH},
1046+
collections::{HashMap, HashSet}, sync::{atomic::AtomicU32, Arc}, time::{Duration, SystemTime, UNIX_EPOCH}
10461047
};
10471048

10481049
use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient};
@@ -1123,7 +1124,7 @@ pub mod tests {
11231124
}
11241125
}
11251126
}
1126-
1127+
11271128
pub static PREFIX_ID: AtomicU32 = AtomicU32::new(0);
11281129
const DUMMY_URL: &str = "http://localhost:1234";
11291130
const TRIGGER_VALUE: u128 = 500;

crates/tap-agent/src/agent/sender_accounts_manager.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ mod tests {
655655
}))
656656
}
657657

658+
659+
const DUMMY_ADDR: &str = "http://localhost:1234";
658660
async fn create_sender_accounts_manager(
659661
pgpool: PgPool,
660662
) -> (
@@ -683,8 +685,8 @@ mod tests {
683685
escrow_subgraph,
684686
network_subgraph,
685687
sender_aggregator_endpoints: HashMap::from([
686-
(SENDER.1, Url::parse("http://localhost:8000").unwrap()),
687-
(SENDER_2.1, Url::parse("http://localhost:8000").unwrap()),
688+
(SENDER.1, Url::parse(DUMMY_ADDR).unwrap()),
689+
(SENDER_2.1, Url::parse(DUMMY_ADDR).unwrap()),
688690
]),
689691
prefix: Some(prefix.clone()),
690692
};
@@ -704,6 +706,7 @@ mod tests {
704706
join_handle.await.unwrap();
705707
}
706708

709+
const SENDER_DUMMY_ADDR: &str = "http://localhost:1234";
707710
async fn create_state(pgpool: PgPool) -> (String, State) {
708711
let config = get_config();
709712
let senders_to_signers = vec![(SENDER.1, vec![SIGNER.1])].into_iter().collect();
@@ -727,8 +730,8 @@ mod tests {
727730
escrow_subgraph: get_subgraph_client().await,
728731
network_subgraph: get_subgraph_client().await,
729732
sender_aggregator_endpoints: HashMap::from([
730-
(SENDER.1, Url::parse("http://localhost:8000").unwrap()),
731-
(SENDER_2.1, Url::parse("http://localhost:8000").unwrap()),
733+
(SENDER.1, Url::parse(SENDER_DUMMY_ADDR).unwrap()),
734+
(SENDER_2.1, Url::parse(SENDER_DUMMY_ADDR).unwrap()),
732735
]),
733736
prefix: Some(prefix),
734737
},

crates/tap-agent/src/agent/sender_allocation.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,13 @@ pub mod tests {
953953
.unwrap()
954954
.connect_timeout(Duration::default());
955955

956-
957-
let sender_aggregator = TapAggregatorClient::connect(endpoint)
956+
957+
let sender_aggregator = TapAggregatorClient::connect(endpoint.clone())
958958
.await
959-
.expect("Failed to connect to the TapAggregator endpoint")
959+
.expect(&format!(
960+
"Failed to connect to the TapAggregator endpoint '{}'",
961+
endpoint.uri()
962+
))
960963
.send_compressed(tonic::codec::CompressionEncoding::Zstd);
961964

962965
SenderAllocationArgs {
@@ -1373,7 +1376,7 @@ pub mod tests {
13731376
// check if the actor is actually stopped
13741377
assert_eq!(sender_allocation.get_status(), ActorStatus::Stopped);
13751378
}
1376-
1379+
13771380
#[sqlx::test(migrations = "../../migrations")]
13781381
async fn should_return_unaggregated_fees_without_rav(pgpool: PgPool) {
13791382
let (mock_escrow_subgraph_server, _mock_ecrow_subgraph) = mock_escrow_subgraph().await;

0 commit comments

Comments
 (0)