Skip to content

Commit

Permalink
Checkpoint end to end test (MystenLabs#2475)
Browse files Browse the repository at this point in the history
Checkpoint end to end test
  • Loading branch information
asonnino authored Jun 8, 2022
1 parent 82d83e2 commit cdfd8dc
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 136 deletions.
4 changes: 2 additions & 2 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl ValidatorInfo {
}
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)]
pub struct Genesis {
#[serde(flatten)]
location: GenesisLocation,
Expand Down Expand Up @@ -188,7 +188,7 @@ impl Genesis {
}
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)]
#[serde(untagged)]
enum GenesisLocation {
InPlace {
Expand Down
13 changes: 9 additions & 4 deletions crates/sui-core/src/authority_active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl<A> ActiveAuthority<A> {
})
}

#[cfg(test)]
pub fn new_with_ephemeral_follower_store(
authority: Arc<AuthorityState>,
authority_clients: BTreeMap<AuthorityName, A>,
Expand Down Expand Up @@ -205,11 +204,17 @@ where
A: AuthorityAPI + Send + Sync + 'static + Clone,
{
pub async fn spawn_all_active_processes(self) {
self.spawn_active_processes(true, true).await
self.spawn_active_processes(true, true, CheckpointProcessControl::default())
.await
}

/// Spawn all active tasks.
pub async fn spawn_active_processes(self, gossip: bool, checkpoint: bool) {
pub async fn spawn_active_processes(
self,
gossip: bool,
checkpoint: bool,
checkpoint_process_control: CheckpointProcessControl,
) {
let active = Arc::new(self);
// Spawn a task to take care of gossip
let gossip_locals = active.clone();
Expand All @@ -223,7 +228,7 @@ where
let checkpoint_locals = active; // .clone();
let _checkpoint_join = tokio::task::spawn(async move {
if checkpoint {
checkpoint_process(&checkpoint_locals, &CheckpointProcessControl::default()).await;
checkpoint_process(&checkpoint_locals, &checkpoint_process_control).await;
}
});

Expand Down
14 changes: 10 additions & 4 deletions crates/sui-core/src/authority_active/checkpoint_driver/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
authority_active::ActiveAuthority, authority_client::LocalAuthorityClient,
checkpoints::checkpoint_tests::TestSetup, safe_client::SafeClient,
authority_active::{checkpoint_driver::CheckpointProcessControl, ActiveAuthority},
authority_client::LocalAuthorityClient,
checkpoints::checkpoint_tests::TestSetup,
safe_client::SafeClient,
};

use std::{collections::BTreeSet, time::Duration};
Expand Down Expand Up @@ -107,7 +109,9 @@ async fn checkpoint_active_flow_crash_client_with_gossip() {
)
.unwrap();
// Spin the gossip service.
active_state.spawn_active_processes(true, true).await;
active_state
.spawn_active_processes(true, true, CheckpointProcessControl::default())
.await;
});
}

Expand Down Expand Up @@ -193,7 +197,9 @@ async fn checkpoint_active_flow_crash_client_no_gossip() {
)
.unwrap();
// Spin the gossip service.
active_state.spawn_active_processes(false, true).await;
active_state
.spawn_active_processes(false, true, CheckpointProcessControl::default())
.await;
});
}

Expand Down
1 change: 0 additions & 1 deletion crates/sui-core/src/authority_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ impl LocalAuthorityClient {
client
}

#[cfg(test)]
pub fn new_from_authority(state: Arc<AuthorityState>) -> Self {
Self {
state,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-faucet/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
#[derive(Error, Debug, PartialEq, Eq)]
pub enum FaucetError {
#[error("Faucet does not have enough balance")]
InsuffientBalance,
Expand Down
11 changes: 6 additions & 5 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use move_vm_runtime::{
};
use once_cell::sync::Lazy;
use rand::{rngs::StdRng, Rng, SeedableRng};
use std::fmt::Write;
use std::{
collections::{BTreeMap, BTreeSet},
path::Path,
Expand Down Expand Up @@ -184,7 +185,7 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
if !output.is_empty() {
output.push_str(", ")
}
output.push_str(&format!("{}: object({})", account, fake))
write!(output, "{}: object({})", account, fake).unwrap()
}
for object_id in object_ids {
test_adapter.enumerate_fake(object_id);
Expand Down Expand Up @@ -564,26 +565,26 @@ impl<'a> SuiTestAdapter<'a> {
if events.is_empty() {
out += "No events"
} else {
out += &format!("events: {}", self.list_events(events))
write!(out, "events: {}", self.list_events(events)).unwrap();
}
}
if !created.is_empty() {
if !out.is_empty() {
out.push('\n')
}
out += &format!("created: {}", self.list_objs(created));
write!(out, "created: {}", self.list_objs(created)).unwrap();
}
if !written.is_empty() {
if !out.is_empty() {
out.push('\n')
}
out += &format!("written: {}", self.list_objs(written));
write!(out, "written: {}", self.list_objs(written)).unwrap();
}
if !deleted.is_empty() {
if !out.is_empty() {
out.push('\n')
}
out += &format!("deleted: {}", self.list_objs(deleted));
write!(out, "deleted: {}", self.list_objs(deleted)).unwrap();
}

if out.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
};

/// A universal Sui event type encapsulating different types of events
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EventEnvelope {
/// UTC timestamp in milliseconds since epoch (1/1/1970)
timestamp: u64,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
object::Object,
};

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum DeleteKind {
/// An object is provided in the call input, and gets deleted.
Normal,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/waypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
}
}

impl<'a, K, I> WaypointDiff<K, I>
impl<K, I> WaypointDiff<K, I>
where
I: 'static + Ord + IntoPoint,
K: 'static,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-verifier/src/id_leak_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn verify_id_leak(module: &CompiledModule) -> SuiResult {
Ok(())
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct AbstractState {
locals: BTreeMap<LocalIndex, AbstractValue>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/benchmark/bench_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct Benchmark {
pub bench_type: BenchmarkType,
}

#[derive(Parser, Debug, Clone, PartialEq, EnumString)]
#[derive(Parser, Debug, Clone, PartialEq, EnumString, Eq)]
#[clap(rename_all = "kebab-case")]
pub enum BenchmarkType {
#[clap(name = "microbench")]
Expand Down
Loading

0 comments on commit cdfd8dc

Please sign in to comment.