Skip to content

Commit 4b6d310

Browse files
committed
review fixes
1 parent e74e09d commit 4b6d310

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

trust-quorum/src/established_conn.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl EstablishedConn {
190190
debug!(self.log, "Received {msg:?}");
191191
match msg {
192192
WireMsg::Tq(msg) => {
193-
if let Err(_) = self.main_tx.try_send(ConnToMainMsg {
193+
if let Err(e) = self.main_tx.try_send(ConnToMainMsg {
194194
task_id: self.task_id,
195195
msg: ConnToMainMsgInner::Received {
196196
from: self.peer_id.clone(),
@@ -201,7 +201,7 @@ impl EstablishedConn {
201201
self.log,
202202
"Failed to send received fsm msg to main task"
203203
);
204-
panic!("Connection to main task channel full");
204+
panic!("Connection to main task channel error: {e:#?}");
205205
}
206206
}
207207
WireMsg::Ping => {
@@ -210,7 +210,7 @@ impl EstablishedConn {
210210
}
211211
WireMsg::NetworkConfig(config) => {
212212
let generation = config.generation;
213-
if let Err(_) = self.main_tx.try_send(ConnToMainMsg {
213+
if let Err(e) = self.main_tx.try_send(ConnToMainMsg {
214214
task_id: self.task_id,
215215
msg: ConnToMainMsgInner::ReceivedNetworkConfig {
216216
from: self.peer_id.clone(),
@@ -222,11 +222,11 @@ impl EstablishedConn {
222222
"Failed to send received NetworkConfig with
223223
generation {generation} to main task"
224224
);
225-
panic!("Connection to main task channnel full");
225+
panic!("Connection to main task channel error: {e:#?}");
226226
}
227227
}
228228
WireMsg::ProxyRequest(req) => {
229-
if let Err(_) = self.main_tx.try_send(ConnToMainMsg {
229+
if let Err(e) = self.main_tx.try_send(ConnToMainMsg {
230230
task_id: self.task_id,
231231
msg: ConnToMainMsgInner::ProxyRequestReceived {
232232
from: self.peer_id.clone(),
@@ -235,13 +235,13 @@ impl EstablishedConn {
235235
}) {
236236
error!(
237237
self.log,
238-
"Failed to send received proxy msg to the main task"
238+
"Failed to send received proxy request to the main task"
239239
);
240-
panic!("Connection to main task channel full");
240+
panic!("Connection to main task channel error: {e:#?}");
241241
}
242242
}
243243
WireMsg::ProxyResponse(rsp) => {
244-
if let Err(_) = self.main_tx.try_send(ConnToMainMsg {
244+
if let Err(e) = self.main_tx.try_send(ConnToMainMsg {
245245
task_id: self.task_id,
246246
msg: ConnToMainMsgInner::ProxyResponseReceived {
247247
from: self.peer_id.clone(),
@@ -250,9 +250,9 @@ impl EstablishedConn {
250250
}) {
251251
error!(
252252
self.log,
253-
"Failed to send received proxy msg to the main task"
253+
"Failed to send received proxy resposne to the main task"
254254
);
255-
panic!("Connection to main task channel full");
255+
panic!("Connection to main task channel error: {e:#?}");
256256
}
257257
}
258258
}

trust-quorum/src/proxy.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ mod tests {
374374
let proxy = Proxy::new(tx.clone());
375375
let mut tracker = Tracker::new();
376376

377+
// All spawned tasks will increment this value when processing a
378+
// request. The result is polled with `wait_for_condition` at the end
379+
// of the test, and therefore there is no reason to join on any of the
380+
// spawned test tasks.
377381
let requests_completed = Arc::new(AtomicUsize::new(0));
378382

379383
// This is the first "user" task that will issue proxy operations
@@ -474,15 +478,17 @@ mod tests {
474478
// connections here, so just use an ID of an arbitrary task.
475479
let task_id = task::spawn(async {}).id();
476480

481+
// All spawned tasks will increment this value when processing a
482+
// request. The result is polled with `wait_for_condition` at the end
483+
// of the test, and therefore there is no reason to join on any of the
484+
// spawned test tasks.
477485
let requests_completed = Arc::new(AtomicUsize::new(0));
478486

479487
// This is the first "user" task that will issue proxy operations
480488
let count = requests_completed.clone();
481489
let dest = destination.clone();
482490
let _ = spawn(async move {
483491
let s = proxy.commit(dest, rack_id, Epoch(1)).await.unwrap_err();
484-
485-
// The first attempt should succeed
486492
assert_matches!(s, ProxyError::InvalidResponse(_));
487493
let _ = count.fetch_add(1, Ordering::Relaxed);
488494
});
@@ -546,15 +552,17 @@ mod tests {
546552
let proxy = Proxy::new(tx.clone());
547553
let mut tracker = Tracker::new();
548554

555+
// All spawned tasks will increment this value when processing a
556+
// request. The result is polled with `wait_for_condition` at the end
557+
// of the test, and therefore there is no reason to join on any of the
558+
// spawned test tasks.
549559
let requests_completed = Arc::new(AtomicUsize::new(0));
550560

551561
// This is the first "user" task that will issue proxy operations
552562
let count = requests_completed.clone();
553563
let dest = destination.clone();
554564
let _ = spawn(async move {
555565
let s = proxy.commit(dest, rack_id, Epoch(1)).await.unwrap_err();
556-
557-
// The first attempt should succeed
558566
assert_eq!(s, ProxyError::Disconnected);
559567
let _ = count.fetch_add(1, Ordering::Relaxed);
560568
});

trust-quorum/src/task.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ mod tests {
13911391
/// at the first 3 nodes. Then we go and issue a `PrepareAndCommit` to the last
13921392
/// node and ensure it commits.
13931393
#[tokio::test]
1394-
pub async fn tq_initial_config_prepare_and_commit() {
1394+
async fn tq_initial_config_prepare_and_commit() {
13951395
let num_nodes = 4;
13961396
let setup = TestSetup::spawn_nodes(
13971397
"tq_initial_config_prepare_and_commit",
@@ -1526,7 +1526,7 @@ mod tests {
15261526
/// the configuration for the prior epoch. This should result in commit
15271527
/// advancing to the latest epoch.
15281528
#[tokio::test]
1529-
pub async fn tq_reconfig_with_commit_advance() {
1529+
async fn tq_reconfig_with_commit_advance() {
15301530
let num_nodes = 4;
15311531
let setup = TestSetup::spawn_nodes(
15321532
"tq_recofnig_with_commit_advance",
@@ -1744,7 +1744,7 @@ mod tests {
17441744
}
17451745

17461746
#[tokio::test]
1747-
pub async fn tq_upgrade_from_lrtq() {
1747+
async fn tq_upgrade_from_lrtq() {
17481748
let num_nodes = 4;
17491749
let (setup, rack_id) = TestSetup::spawn_nodes_with_lrtq_shares(
17501750
"tq_upgrade_from_lrtq",
@@ -1831,7 +1831,7 @@ mod tests {
18311831

18321832
/// Ensure state is persisted as we expect
18331833
#[tokio::test]
1834-
pub async fn tq_persistent_state() {
1834+
async fn tq_persistent_state() {
18351835
let num_nodes = 4;
18361836
let mut setup =
18371837
TestSetup::spawn_nodes("tq_initial_config", num_nodes).await;
@@ -2117,7 +2117,7 @@ mod tests {
21172117

21182118
/// Proxy API requests to other nodes
21192119
#[tokio::test]
2120-
pub async fn tq_proxy() {
2120+
async fn tq_proxy() {
21212121
let num_nodes = 4;
21222122
let mut setup = TestSetup::spawn_nodes("tq_proxy", num_nodes).await;
21232123
let rack_id = RackUuid::new_v4();

0 commit comments

Comments
 (0)