Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Only report concluded if there is an actual dispute. #6270

Merged
merged 4 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Test for no onesided disputes.
  • Loading branch information
eskimor committed Nov 14, 2022
commit de07e15f9f9b7fc8818ae03fc1ae66fbed2daa38
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/core/dispute-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ assert_matches = "1.4.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
futures-timer = "3.0.2"
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }

[features]
# If not enabled, the dispute coordinator will do nothing.
Expand Down
62 changes: 62 additions & 0 deletions node/core/dispute-coordinator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2787,3 +2787,65 @@ fn redundant_votes_ignored() {
})
});
}

#[test]
/// Make sure no disputes are recorded when there are no opposing votes, even if we reached supermajority.
fn no_onesided_disputes() {
sp_tracing::try_init_simple();
test_harness(|mut test_state, mut virtual_overseer| {
Box::pin(async move {
let session = 1;

test_state.handle_resume_sync(&mut virtual_overseer, session).await;

let candidate_receipt = make_valid_candidate_receipt();
let candidate_hash = candidate_receipt.hash();

test_state.activate_leaf_at_session(&mut virtual_overseer, session, 1).await;

let mut statements = Vec::new();
for index in 1..10 {
statements.push((
test_state
.issue_backing_statement_with_index(
ValidatorIndex(index),
candidate_hash,
session,
)
.await,
ValidatorIndex(index),
));
}

let (pending_confirmation, confirmation_rx) = oneshot::channel();
virtual_overseer
.send(FromOrchestra::Communication {
msg: DisputeCoordinatorMessage::ImportStatements {
candidate_receipt: candidate_receipt.clone(),
session,
statements,
pending_confirmation: Some(pending_confirmation),
},
})
.await;
assert_matches!(confirmation_rx.await, Ok(ImportStatementsResult::ValidImport));

// We should not have any active disputes now.
let (tx, rx) = oneshot::channel();
virtual_overseer
.send(FromOrchestra::Communication {
msg: DisputeCoordinatorMessage::ActiveDisputes(tx),
})
.await;

assert!(rx.await.unwrap().is_empty());

virtual_overseer.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;

// No more messages expected:
assert!(virtual_overseer.try_recv().await.is_none());

test_state
})
});
}