Skip to content

Commit

Permalink
use simple commit round in rejoin itest
Browse files Browse the repository at this point in the history
  • Loading branch information
hhalex committed Jan 6, 2025
1 parent 33fad2a commit 764d580
Showing 1 changed file with 16 additions and 84 deletions.
100 changes: 16 additions & 84 deletions src/autobahn_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ macro_rules! send {
}

macro_rules! simple_commit_round {
(leader: $leader:ident, followers: [$($follower:ident),+]) => {{
(leader: $leader:expr, followers: [$($follower:expr),+]$(, joining: $joining:expr)?) => {{
let round_consensus_proposal;
let round_ticket;
broadcast! {
description: "Leader - Prepare",
from: $leader, to: [$($follower),+],
from: $leader, to: [$($follower),+$(,$joining)?],
message_matches: ConsensusNetMessage::Prepare(cp, ticket) => {
round_consensus_proposal = cp.clone();
round_ticket = ticket.clone();
Expand All @@ -148,7 +148,7 @@ macro_rules! simple_commit_round {

broadcast! {
description: "Leader - Confirm",
from: $leader, to: [$($follower),+],
from: $leader, to: [$($follower),+$(,$joining)?],
message_matches: ConsensusNetMessage::Confirm(_)
};

Expand All @@ -160,7 +160,7 @@ macro_rules! simple_commit_round {

broadcast! {
description: "Leader - Commit",
from: $leader, to: [$($follower),+],
from: $leader, to: [$($follower),+$(,$joining)?],
message_matches: ConsensusNetMessage::Commit(_, _)
};

Expand Down Expand Up @@ -488,33 +488,10 @@ async fn autobahn_rejoin_flow() {
for _ in 0..3 {
node1.start_round_with_cut_from_mempool().await;

broadcast! {
description: "Prepare",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx]
};

send! {
description: "PrepareVote",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::PrepareVote(_)
};

broadcast! {
description: "Confirm",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx], // joining_node doesn't need it but sending for consistency
message_matches: ConsensusNetMessage::Confirm(_)
};

send! {
description: "ConfirmAck",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::ConfirmAck(_)
};

broadcast! {
description: "Commit",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx],
message_matches: ConsensusNetMessage::Commit(_, _)
simple_commit_round! {
leader: node1.consensus_ctx,
followers: [node2.consensus_ctx],
joining: joining_node.consensus_ctx
};

// Swap so we handle leader changes correctly
Expand All @@ -535,34 +512,12 @@ async fn autobahn_rejoin_flow() {
// Process round
node1.start_round_with_cut_from_mempool().await;

broadcast! {
description: "Prepare",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx]
};

send! {
description: "PrepareVote",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::PrepareVote(_)
};

broadcast! {
description: "Confirm",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx], // joining_node doesn't need it but sending for consistency
message_matches: ConsensusNetMessage::Confirm(_)
};

send! {
description: "ConfirmAck",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::ConfirmAck(_)
simple_commit_round! {
leader: node1.consensus_ctx,
followers: [node2.consensus_ctx],
joining: joining_node.consensus_ctx
};

broadcast! {
description: "Commit",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx],
message_matches: ConsensusNetMessage::Commit(_, _)
};
std::mem::swap(&mut node1, &mut node2);

// We still aren't caught up
Expand Down Expand Up @@ -594,33 +549,10 @@ async fn autobahn_rejoin_flow() {
// Process round
node1.start_round_with_cut_from_mempool().await;

broadcast! {
description: "Prepare",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx]
};

send! {
description: "PrepareVote",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::PrepareVote(_)
};

broadcast! {
description: "Confirm",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx], // joining_node doesn't need it but sending for consistency
message_matches: ConsensusNetMessage::Confirm(_)
};

send! {
description: "ConfirmAck",
from: [node2.consensus_ctx], to: node1.consensus_ctx,
message_matches: ConsensusNetMessage::ConfirmAck(_)
};

broadcast! {
description: "Commit",
from: node1.consensus_ctx, to: [node2.consensus_ctx, joining_node.consensus_ctx],
message_matches: ConsensusNetMessage::Commit(_, _)
simple_commit_round! {
leader: node1.consensus_ctx,
followers: [node2.consensus_ctx],
joining: joining_node.consensus_ctx
};

// We are caught up
Expand Down

0 comments on commit 764d580

Please sign in to comment.