forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
substrate/primitives/application-crypto/test/src/bls381.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use sp_api::{ApiExt, ProvideRuntimeApi}; | ||
use sp_application_crypto::ecdsa::AppPair; | ||
use sp_core::{ | ||
crypto::{ByteArray, Pair}, | ||
testing::BLS381, | ||
}; | ||
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; | ||
use std::sync::Arc; | ||
use substrate_test_runtime_client::{ | ||
runtime::TestAPI, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, | ||
}; | ||
|
||
#[test] | ||
fn bls381_works_in_runtime() { | ||
let keystore = Arc::new(MemoryKeystore::new()); | ||
let test_client = TestClientBuilder::new().build(); | ||
|
||
let mut runtime_api = test_client.runtime_api(); | ||
runtime_api.register_extension(KeystoreExt::new(keystore.clone())); | ||
|
||
let (signature, public) = runtime_api | ||
.test_bls381_crypto(test_client.chain_info().genesis_hash) | ||
.expect("Tests `bls381` crypto."); | ||
|
||
let supported_keys = keystore.keys(BLS381).unwrap(); | ||
assert!(supported_keys.contains(&public.to_raw_vec())); | ||
assert!(AppPair::verify(&signature, "bls381", &public)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ mod ecdsa; | |
mod ed25519; | ||
#[cfg(test)] | ||
mod sr25519; | ||
#[cfg(all(test, feature = "bls-experimental"))] | ||
mod bls381; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters