mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
Make BEEFY client keystore generic over BEEFY AuthorityId type (#2258)
This is the significant step to make BEEFY client able to handle both ECDSA and (ECDSA, BLS) type signature. The idea is having BEEFY Client generic on crypto types makes migration to new types smoother. This makes the BEEFY Keystore generic over AuthorityId and extends its tests to cover the case when the AuthorityId is of type (ECDSA, BLS12-377) --------- Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Robert Hambrock <roberthambrock@gmail.com>
This commit is contained in:
@@ -485,8 +485,8 @@ pub(crate) mod tests {
|
||||
use sc_network_test::Block;
|
||||
use sp_application_crypto::key_types::BEEFY as BEEFY_KEY_TYPE;
|
||||
use sp_consensus_beefy::{
|
||||
ecdsa_crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload,
|
||||
SignedCommitment, VoteMessage,
|
||||
ecdsa_crypto::Signature, known_payloads, test_utils::Keyring, Commitment, MmrRootHash,
|
||||
Payload, SignedCommitment, VoteMessage,
|
||||
};
|
||||
use sp_keystore::{testing::MemoryKeystore, Keystore};
|
||||
|
||||
@@ -507,10 +507,13 @@ pub(crate) mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sign_commitment<BN: Encode>(who: &Keyring, commitment: &Commitment<BN>) -> Signature {
|
||||
pub fn sign_commitment<BN: Encode>(
|
||||
who: &Keyring<AuthorityId>,
|
||||
commitment: &Commitment<BN>,
|
||||
) -> Signature {
|
||||
let store = MemoryKeystore::new();
|
||||
store.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&who.to_seed())).unwrap();
|
||||
let beefy_keystore: BeefyKeystore = Some(store.into()).into();
|
||||
let beefy_keystore: BeefyKeystore<AuthorityId> = Some(store.into()).into();
|
||||
beefy_keystore.sign(&who.public(), &commitment.encode()).unwrap()
|
||||
}
|
||||
|
||||
@@ -538,7 +541,10 @@ pub(crate) mod tests {
|
||||
.validators()
|
||||
.iter()
|
||||
.map(|validator: &AuthorityId| {
|
||||
Some(sign_commitment(&Keyring::from_public(validator).unwrap(), &commitment))
|
||||
Some(sign_commitment(
|
||||
&Keyring::<AuthorityId>::from_public(validator).unwrap(),
|
||||
&commitment,
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -547,7 +553,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn should_validate_messages() {
|
||||
let keys = vec![Keyring::Alice.public()];
|
||||
let keys = vec![Keyring::<AuthorityId>::Alice.public()];
|
||||
let validator_set = ValidatorSet::<AuthorityId>::new(keys.clone(), 0).unwrap();
|
||||
let (gv, mut report_stream) =
|
||||
GossipValidator::<Block>::new(Arc::new(Mutex::new(KnownPeers::new())));
|
||||
|
||||
Reference in New Issue
Block a user