File tree Expand file tree Collapse file tree 4 files changed +42
-6
lines changed
Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub enum InjectFailureTrigger {
2626 ProposalDecided ,
2727 ProposalCommitted ,
2828 OutdatedVote ,
29+ ProposalCommittedSilently ,
2930}
3031
3132impl InjectFailureTrigger {
@@ -42,6 +43,7 @@ impl InjectFailureTrigger {
4243 InjectFailureTrigger :: ProposalDecided => "proposal_decided" ,
4344 InjectFailureTrigger :: ProposalCommitted => "proposal_committed" ,
4445 InjectFailureTrigger :: OutdatedVote => "outdated_vote" ,
46+ InjectFailureTrigger :: ProposalCommittedSilently => "proposal_committed_silently" ,
4547 }
4648 }
4749}
@@ -62,6 +64,7 @@ impl FromStr for InjectFailureTrigger {
6264 "proposal_decided" => Ok ( InjectFailureTrigger :: ProposalDecided ) ,
6365 "proposal_committed" => Ok ( InjectFailureTrigger :: ProposalCommitted ) ,
6466 "outdated_vote" => Ok ( InjectFailureTrigger :: OutdatedVote ) ,
67+ "proposal_committed_silently" => Ok ( InjectFailureTrigger :: ProposalCommittedSilently ) ,
6568 _ => Err ( format ! ( "Unknown inject failure event: {s}" ) ) ,
6669 }
6770 }
Original file line number Diff line number Diff line change @@ -146,7 +146,13 @@ pub fn debug_fail_on_proposal_committed(
146146 data_directory : & Path ,
147147) {
148148 debug_fail_on (
149- |trigger| matches ! ( trigger, InjectFailureTrigger :: ProposalCommitted ) ,
149+ |trigger| {
150+ matches ! (
151+ trigger,
152+ InjectFailureTrigger :: ProposalCommitted
153+ | InjectFailureTrigger :: ProposalCommittedSilently
154+ )
155+ } ,
150156 height,
151157 inject_failure,
152158 data_directory,
@@ -215,3 +221,29 @@ pub fn send_outdated_vote(
215221) -> bool {
216222 false
217223}
224+
225+ #[ cfg( all(
226+ feature = "p2p" ,
227+ feature = "consensus-integration-tests" ,
228+ debug_assertions
229+ ) ) ]
230+ pub fn do_not_send_vote ( vote_height : u64 , inject_failure : Option < InjectFailureConfig > ) -> bool {
231+ matches ! ( inject_failure,
232+ Some ( InjectFailureConfig {
233+ height,
234+ trigger: InjectFailureTrigger :: ProposalCommittedSilently ,
235+ } ) if vote_height >= height
236+ )
237+ }
238+
239+ #[ cfg( not( all(
240+ feature = "p2p" ,
241+ feature = "consensus-integration-tests" ,
242+ debug_assertions
243+ ) ) ) ]
244+ pub fn do_not_send_vote (
245+ _proposal_height : u64 ,
246+ _inject_failure : Option < InjectFailureConfig > ,
247+ ) -> bool {
248+ false
249+ }
Original file line number Diff line number Diff line change @@ -683,7 +683,10 @@ pub fn spawn(
683683 . await ?;
684684 }
685685 ComputationSuccess :: GossipVote ( vote) => {
686- gossip_handler. gossip_vote ( & p2p_client, vote) . await ?;
686+ // The condition is always true in production builds.
687+ if !integration_testing:: do_not_send_vote ( vote. height , inject_failure) {
688+ gossip_handler. gossip_vote ( & p2p_client, vote) . await ?;
689+ }
687690 }
688691 ComputationSuccess :: PreviouslyDeferredProposalIsFinalized ( hnr, commitment) => {
689692 send_proposal_to_consensus ( & tx_to_consensus, hnr, commitment) . await ;
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ mod test {
7373 #[ case:: fail_on_prevote_rx( Some ( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: PrevoteRx } ) ) ]
7474 #[ case:: fail_on_precommit_rx( Some ( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: PrecommitRx } ) ) ]
7575 #[ case:: fail_on_proposal_decided( Some ( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: ProposalDecided } ) ) ]
76+ #[ case:: fail_on_proposal_committed( Some ( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: ProposalCommitted } ) ) ]
7677 #[ tokio:: test]
7778 async fn consensus_3_nodes_with_failures ( #[ case] inject_failure : Option < InjectFailureConfig > ) {
7879 const NUM_NODES : usize = 3 ;
@@ -233,10 +234,7 @@ mod test {
233234 }
234235
235236 #[ rstest]
236- // Cannot be tested with just 3 nodes b/c Bob might break the
237- // Gossip communication property when restarting - see
238- // https://github.com/eqlabs/pathfinder/issues/3286
239- #[ case:: fail_on_proposal_committed( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: ProposalCommitted } ) ]
237+ #[ case:: fail_on_proposal_committed( InjectFailureConfig { height: 4 , trigger: InjectFailureTrigger :: ProposalCommittedSilently } ) ]
240238 #[ tokio:: test]
241239 async fn consensus_4_nodes_with_failures ( #[ case] inject_failure : InjectFailureConfig ) {
242240 const NUM_NODES : usize = 4 ;
You can’t perform that action at this time.
0 commit comments