Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions primitives/src/v1/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,20 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> UncheckedSigned<Payloa
/// Sign this payload with the given context and pair. Only for runtime benchmark use cases.
#[cfg(feature = "runtime-benchmarks")]
pub fn benchmark_sign<H: Encode>(
pair: &crate::v0::ValidatorPair,
public: &crate::v0::ValidatorId,
payload: Payload,
context: &SigningContext<H>,
validator_index: ValidatorIndex,
) -> Self {
use application_crypto::Pair;
// use application_crypto::Pair;
use application_crypto::RuntimeAppPublic;
let data = Self::payload_data(&payload, context);
let signature = pair.sign(&data);

// let debug_res = public.sign(&data);
// // println!("debug_res benchmark sign {:?}", debug_res);
// let signature = debug_res.unwrap();
let signature = public.sign(&data).unwrap();
// let signature = pair.sign(&data);

Self { payload, validator_index, signature, real_payload: sp_std::marker::PhantomData }
}
Expand Down
7 changes: 6 additions & 1 deletion runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,19 @@ impl inclusion::RewardValidators for TestRewardValidators {

/// Create a new set of test externalities.
pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities {
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr};
use sp_std::sync::Arc;
BACKING_REWARDS.with(|r| r.borrow_mut().clear());
AVAILABILITY_REWARDS.with(|r| r.borrow_mut().clear());

let mut t = state.system.build_storage::<Test>().unwrap();
state.configuration.assimilate_storage(&mut t).unwrap();
GenesisBuild::<Test>::assimilate_storage(&state.paras, &mut t).unwrap();

t.into()
let mut ext: TestExternalities = t.into();
ext.register_extension(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr));
Comment on lines +313 to +314
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to fix the issue with using the keystore when running tests


ext
}

#[derive(Default)]
Expand Down
Loading