mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
Do not stall on lost transaction (#1903)
* `select_nonces_to_deliver` is no longer `&mut self` * reset submitted nonces on lost transaction * clippy * fmt
This commit is contained in:
committed by
Bastian Köcher
parent
e7debc4b09
commit
dd58493ea4
@@ -1017,58 +1017,6 @@ pub(crate) mod tests {
|
||||
assert_eq!(result.submitted_messages_proofs, vec![(1..=1, None)],);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_lane_loop_is_able_to_recover_from_race_stall() {
|
||||
// with this configuration, both source and target clients will lose their transactions =>
|
||||
// reconnect will happen
|
||||
let (source_exit_sender, exit_receiver) = unbounded();
|
||||
let target_exit_sender = source_exit_sender.clone();
|
||||
let result = run_loop_test(
|
||||
Arc::new(Mutex::new(TestClientData {
|
||||
source_state: ClientState {
|
||||
best_self: HeaderId(0, 0),
|
||||
best_finalized_self: HeaderId(0, 0),
|
||||
best_finalized_peer_at_best_self: Some(HeaderId(0, 0)),
|
||||
actual_best_finalized_peer_at_best_self: Some(HeaderId(0, 0)),
|
||||
},
|
||||
source_latest_generated_nonce: 1,
|
||||
source_tracked_transaction_status: TrackedTransactionStatus::Lost,
|
||||
target_state: ClientState {
|
||||
best_self: HeaderId(0, 0),
|
||||
best_finalized_self: HeaderId(0, 0),
|
||||
best_finalized_peer_at_best_self: Some(HeaderId(0, 0)),
|
||||
actual_best_finalized_peer_at_best_self: Some(HeaderId(0, 0)),
|
||||
},
|
||||
target_latest_received_nonce: 0,
|
||||
target_tracked_transaction_status: TrackedTransactionStatus::Lost,
|
||||
..Default::default()
|
||||
})),
|
||||
Arc::new(move |data: &mut TestClientData| {
|
||||
if data.is_source_reconnected {
|
||||
data.source_tracked_transaction_status =
|
||||
TrackedTransactionStatus::Finalized(Default::default());
|
||||
}
|
||||
if data.is_source_reconnected && data.is_target_reconnected {
|
||||
source_exit_sender.unbounded_send(()).unwrap();
|
||||
}
|
||||
}),
|
||||
Arc::new(|_| {}),
|
||||
Arc::new(move |data: &mut TestClientData| {
|
||||
if data.is_target_reconnected {
|
||||
data.target_tracked_transaction_status =
|
||||
TrackedTransactionStatus::Finalized(Default::default());
|
||||
}
|
||||
if data.is_source_reconnected && data.is_target_reconnected {
|
||||
target_exit_sender.unbounded_send(()).unwrap();
|
||||
}
|
||||
}),
|
||||
Arc::new(|_| {}),
|
||||
exit_receiver.into_future().map(|(_, _)| ()),
|
||||
);
|
||||
|
||||
assert!(result.is_source_reconnected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_lane_loop_is_able_to_recover_from_unsuccessful_transaction() {
|
||||
// with this configuration, both source and target clients will mine their transactions, but
|
||||
@@ -1146,7 +1094,6 @@ pub(crate) mod tests {
|
||||
exit_receiver.into_future().map(|(_, _)| ()),
|
||||
);
|
||||
|
||||
assert!(result.is_source_reconnected);
|
||||
assert_eq!(result.submitted_messages_proofs.len(), 2);
|
||||
assert_eq!(result.submitted_messages_receiving_proofs.len(), 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user