Skip to content

Commit

Permalink
Fix the flaky test_re_propose_validated. (#2123)
Browse files Browse the repository at this point in the history
  • Loading branch information
afck authored Jun 12, 2024
1 parent 29075d7 commit 37a02b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions linera-core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,9 @@ where
let certificate = self
.communicate_chain_action(committee, submit_action, value)
.await?;
self.process_certificate(certificate.clone(), vec![], vec![])
.await?;
if certificate.value().is_confirmed() {
self.process_certificate(certificate.clone(), vec![], vec![])
.await?;
Ok(certificate)
} else {
self.finalize_block(committee, certificate).await
Expand Down
20 changes: 20 additions & 0 deletions linera-core/src/unit_tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::{
node::{
CrossChainMessageDelivery,
NodeError::{self, ClientIoError},
ValidatorNode,
},
test_utils::{FaultType, MemoryStorageBuilder, StorageBuilder, TestBuilder},
updater::CommunicationError,
Expand Down Expand Up @@ -1810,6 +1811,25 @@ where
.burn(None, Amount::from_tokens(3), UserData::default())
.await;
assert!(result.is_err());
let manager = client0
.chain_info_with_manager_values()
.await
.unwrap()
.manager;
// Validator 0 may or may not have processed the validated block before the update was
// canceled due to the errors from the faulty validators. Submit it again to make sure
// it's there, so that client 1 can download and re-propose it later.
let validated_block_certificate = manager.highest_validated().unwrap().clone();
builder
.node(0)
.handle_certificate(
validated_block_certificate,
Vec::new(),
Vec::new(),
CrossChainMessageDelivery::Blocking,
)
.await
.unwrap();

// Client 1 wants to burn 2 tokens. They learn about the proposal in round 0, but now the
// validator 0 is offline, so they don't learn about the validated block and make their own
Expand Down
4 changes: 4 additions & 0 deletions linera-core/src/unit_tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ where
self.validator_clients.iter().cloned().collect()
}

pub fn node(&mut self, index: usize) -> &mut LocalValidatorClient<B::Storage> {
&mut self.validator_clients[index]
}

pub async fn make_storage(&mut self) -> anyhow::Result<B::Storage> {
Ok(self
.genesis_storage_builder
Expand Down

0 comments on commit 37a02b0

Please sign in to comment.