grandpa: store the authority id that is used for voting per round (#7454)

* grandpa: store the authority id that is used for voting per round

* grandpa: fix tests
This commit is contained in:
André Silva
2020-11-05 14:36:35 +00:00
committed by GitHub
parent 6328f8740c
commit 47815a5936
3 changed files with 70 additions and 16 deletions
@@ -1713,6 +1713,10 @@ fn grandpa_environment_never_overwrites_round_voter_state() {
assert_eq!(get_current_round(2).unwrap(), HasVoted::No);
// we need to call `round_data` for the next round to pick up
// from the keystore which authority id we'll be using to vote
environment.round_data(2);
let info = peer.client().info();
let prevote = finality_grandpa::Prevote {
@@ -1816,6 +1820,8 @@ fn imports_justification_for_regular_blocks_on_import() {
#[test]
fn grandpa_environment_doesnt_send_equivocation_reports_for_itself() {
use finality_grandpa::voter::Environment;
let alice = Ed25519Keyring::Alice;
let voters = make_ids(&[alice]);
@@ -1845,6 +1851,10 @@ fn grandpa_environment_doesnt_send_equivocation_reports_for_itself() {
second: signed_prevote.clone(),
};
// we need to call `round_data` to pick up from the keystore which
// authority id we'll be using to vote
environment.round_data(1);
// reporting the equivocation should fail since the offender is a local
// authority (i.e. we have keys in our keystore for the given id)
let equivocation_proof = sp_finality_grandpa::Equivocation::Prevote(equivocation.clone());