Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #1096 #1153

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions sui_core/src/unit_tests/consensus_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,11 @@ async fn handle_consensus_output() {
.await
.unwrap();

// Wait for the certificate to be processed and ensure the last consensus index
// has been updated.
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
assert_eq!(
state.db().last_consensus_index().unwrap(),
SequenceNumber::from(1)
);
// Wait for the certificate to be processed and ensure the last consensus index is correctly updated.
// (We need to wait on storage for that.)
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(1) {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
}
Comment on lines +155 to +157
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to do that actually? Something like the notify_read we had in Narwhal perhaps

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notify_read is in typed_store and you should be able to use it anywhere you have a Store. But it is fundamentally an async API ..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to build a notification infra like for the batches to do that. Probably, this will be necessary as new consensus items should trigger execution out of band, but we will cross that bridge when we get to it.


// Cleanup the storage.
let _ = std::fs::remove_dir_all(store_path);
Expand Down Expand Up @@ -229,14 +227,11 @@ async fn sync_with_consensus() {
.await
.unwrap();

// Wait for the certificate to be processed.
tokio::time::sleep(std::time::Duration::from_millis(100)).await;

// Ensure the last consensus index is correctly updated.
assert_eq!(
state.db().last_consensus_index().unwrap(),
SequenceNumber::from(2)
);
// Wait for the certificate to be processed and ensure the last consensus index is correctly updated.
// (We need to wait on storage for that.)
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(2) {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
}

// Ensure the version number of the shared object is correctly updated.
let shared_object_id = test_shared_object().id();
Expand Down