Use sign_with for signing grandpa's outgoing message (#6178)

* Use sign_with and stop using `Pair`

* PR feedback

* Remove clone

* Transfer ownership of public to sign_message

* Use Option

* Simplify code

* Fix error message

* Pass keystore as ref

* Pass keystore properly

* Fix tests
This commit is contained in:
Rakan Alhneiti
2020-06-09 09:39:30 +02:00
committed by GitHub
parent 65ba701f50
commit 2577dde3d9
11 changed files with 95 additions and 61 deletions
@@ -282,7 +282,7 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList {
keys.iter().map(|key| key.clone().public().into()).map(|id| (id, 1)).collect()
}
fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir) {
fn create_keystore(authority: Ed25519Keyring) -> (BareCryptoStorePtr, tempfile::TempDir) {
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
keystore.write().insert_ephemeral_from_seed::<AuthorityPair>(&authority.to_seed())
@@ -1050,7 +1050,7 @@ fn voter_persists_its_votes() {
voter_rx: TracingUnboundedReceiver<()>,
net: Arc<Mutex<GrandpaTestNet>>,
client: PeersClient,
keystore: KeyStorePtr,
keystore: BareCryptoStorePtr,
}
impl Future for ResettableVoter {
@@ -1136,7 +1136,7 @@ fn voter_persists_its_votes() {
let config = Config {
gossip_duration: TEST_GOSSIP_DURATION,
justification_period: 32,
keystore: Some(keystore),
keystore: Some(keystore.clone()),
name: Some(format!("peer#{}", 1)),
is_authority: true,
observer_enabled: true,
@@ -1160,10 +1160,11 @@ fn voter_persists_its_votes() {
);
let (round_rx, round_tx) = network.round_communication(
Some(keystore),
communication::Round(1),
communication::SetId(0),
Arc::new(VoterSet::new(voters).unwrap()),
Some(peers[1].pair().into()),
Some(peers[1].public().into()),
HasVoted::No,
);