Make Test Helpers no_std Compatible (#823)

* Use `sp-application-crypto` when generating test justifications

* Try to justifications tests compiling

* Try using `ed25519_dalek` for justification creation

* Small cleanup

* Correctly generate a Keypair

The public key didn't correspond to what would be derived
with the given private key.

* Remove enum index hack

* Clean up test account helper functions

* Fix tests in `pallet-finality-verifier`

* Get `pallet-substrate-bridge` tests compiling again

* Use the correct keyring in justification tests

* Clean up Keyring related code a bit

* Appease Clippy

* Remove unused import

* Use keyring variants directly

* Remove unecessary From implementation
This commit is contained in:
Hernando Castano
2021-03-18 16:46:52 -04:00
committed by Bastian Köcher
parent 401d3847d1
commit eb7c96ba14
7 changed files with 128 additions and 86 deletions
+6 -4
View File
@@ -59,7 +59,10 @@ use crate::storage::ImportedHeader;
use crate::verifier::*;
use crate::{BestFinalized, BestHeight, BridgeStorage, NextScheduledChange, PalletStorage};
use bp_header_chain::AuthoritySet;
use bp_test_utils::{alice, authority_list, bob, make_justification_for_header};
use bp_test_utils::{
authority_list, keyring, make_justification_for_header,
Keyring::{Alice, Bob},
};
use codec::Encode;
use frame_support::{IterableStorageMap, StorageValue};
use sp_finality_grandpa::{ConsensusLog, GRANDPA_ENGINE_ID};
@@ -456,8 +459,7 @@ where
// See for more: https://github.com/paritytech/parity-bridges-common/issues/430
let grandpa_round = 1;
let set_id = 1;
let authorities = authority_list();
let justification = make_justification_for_header(header, grandpa_round, set_id, &authorities).encode();
let justification = make_justification_for_header(header, grandpa_round, set_id, &keyring()).encode();
let res = verifier
.import_finality_proof(header.hash(), justification.into())
@@ -505,7 +507,7 @@ where
pub(crate) fn change_log(delay: u64) -> Digest<TestHash> {
let consensus_log = ConsensusLog::<TestNumber>::ScheduledChange(sp_finality_grandpa::ScheduledChange {
next_authorities: vec![(alice(), 1), (bob(), 1)],
next_authorities: vec![(Alice.into(), 1), (Bob.into(), 1)],
delay,
});