Fail early at obviously invalid approvals (#3152)

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
This commit is contained in:
Alexandru Gheorghe
2024-01-31 13:41:04 +02:00
committed by GitHub
parent 5354097aa1
commit 261f4b713b
2 changed files with 92 additions and 9 deletions
@@ -3621,6 +3621,33 @@ fn import_versioned_approval() {
assert_eq!(approvals.len(), 1);
}
);
// send an obviously invalid approval
let approval = IndirectSignedApprovalVote {
block_hash: hash,
// Invalid candidate index, should not pass sanitization.
candidate_index: 16777284,
validator: validator_index,
signature: dummy_signature(),
};
let msg = protocol_v2::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
send_message_from_peer_v2(overseer, &peer_a, msg).await;
expect_reputation_change(overseer, &peer_a, COST_OVERSIZED_BITFIELD).await;
// send an obviously invalid approval
let approval = IndirectSignedApprovalVoteV2 {
block_hash: hash,
// Invalid candidates len, should not pass sanitization.
candidate_indices: 16777284.into(),
validator: validator_index,
signature: dummy_signature(),
};
let msg = protocol_v3::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
send_message_from_peer_v3(overseer, &peer_a, msg).await;
expect_reputation_change(overseer, &peer_a, COST_OVERSIZED_BITFIELD).await;
virtual_overseer
});
}