Skip to content

Commit

Permalink
adding feature gating
Browse files Browse the repository at this point in the history
  • Loading branch information
coax1d committed Dec 5, 2024
1 parent 5a244dc commit cc71f5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
9 changes: 7 additions & 2 deletions substrate/primitives/application-crypto/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-api = { workspace = true, default-features = true }
sp-application-crypto = { workspace = true, default-features = true }
sp-core = { workspace = true }
sp-core = { workspace = true, features = ["full_crypto"] }
sp-keystore = { workspace = true }
substrate-test-runtime-client = { workspace = true }

[features]
full_crypto = []
default = ["std"]
std = [
"full_crypto",
]

full_crypto = ["sp-core/full_crypto"]
bls-experimental = []
29 changes: 15 additions & 14 deletions substrate/test-utils/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ decl_runtime_apis! {
/// Test that 'bls381' crypto works in the runtime
///
/// Returns the signature generated for the message `bls381`.
fn test_bls381_crypto() -> (Bls381Signature, Bls381Public);
fn test_bls381_crypto() -> Bls381Public
/// Run various tests against storage.
fn test_storage();
/// Check a witness.
Expand Down Expand Up @@ -606,13 +606,13 @@ impl_runtime_apis! {
}

#[cfg(feature = "bls-experimental")]
fn test_bls381_crypto() -> (Bls381Signature, Bls381Public) {
fn test_bls381_crypto() -> Bls381Public {
test_bls381_crypto()
}

#[cfg(not(feature = "bls-experimental"))]
fn test_bls381_crypto() -> (Bls381Signature, Bls381Public) {
((), ())
fn test_bls381_crypto() -> Bls381Public {
()
}

fn test_storage() {
Expand Down Expand Up @@ -841,22 +841,23 @@ fn test_ecdsa_crypto() -> (ecdsa::AppSignature, ecdsa::AppPublic) {
}

#[cfg(feature = "bls-experimental")]
fn test_bls381_crypto() -> (bls381::AppSignature, bls381::AppPublic) {
fn test_bls381_crypto() -> Bls381Public {
let public0 = bls381::AppPublic::generate_pair(None);
let public1 = bls381::AppPublic::generate_pair(None);
let public2 = bls381::AppPublic::generate_pair(None);
// let public1 = bls381::AppPublic::generate_pair(None);
// let public2 = bls381::AppPublic::generate_pair(None);

let all = bls381::AppPublic::all();
assert!(all.contains(&public0));
assert!(all.contains(&public1));
assert!(all.contains(&public2));
// let all = bls381::AppPublic::all();
// assert!(all.contains(&public0));
// assert!(all.contains(&public1));
// assert!(all.contains(&public2));

// let pop = bls381::AppPublic::generate_pop();

let signature = public0.sign(&"bls381").expect("Generates a valid `bls381` signature.");
// let signature = public0.sign(&"bls381").expect("Generates a valid `bls381` signature.");

assert!(public0.verify(&"bls381", &signature));
(signature, public0)
// assert!(public0.verify(&"bls381", &signature));
// (signature, public0)
// (bls381::AppSignature::from_bytes(&"0"), bls381::AppPublic::from_bytes(&"9"))
}

fn test_read_storage() {
Expand Down

0 comments on commit cc71f5a

Please sign in to comment.