From cb88837f31c292d08f3db6563076deafa90d240d Mon Sep 17 00:00:00 2001 From: driemworks Date: Tue, 14 May 2024 09:23:42 -0500 Subject: [PATCH] update test --- substrate/primitives/keystore/src/testing.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/substrate/primitives/keystore/src/testing.rs b/substrate/primitives/keystore/src/testing.rs index e2b1208a6ed1..52d5a5b42d4c 100644 --- a/substrate/primitives/keystore/src/testing.rs +++ b/substrate/primitives/keystore/src/testing.rs @@ -370,10 +370,8 @@ impl Keystore for MemoryKeystore { ) -> Result { let sig = self.pair::(key_type, public) .map(|pair| pair.acss_recover(pok, threshold)) - .ok_or(return Err(Error::Unavailable))? - .unwrap(); + .unwrap().unwrap(); let extract = sig.sign(&msg); - // return Ok(extract); Ok(extract) } @@ -571,9 +569,7 @@ mod tests { let suri = "//Alice"; let pair = bls377::Pair::from_string(suri, None).unwrap(); - let msg = b"this is a test message"; - // insert key, sign again store.insert(BLS377, suri, pair.public().as_ref()).unwrap(); @@ -588,7 +584,6 @@ mod tests { let mut ibe_pp_bytes = Vec::new(); ibe_pub_param.serialize_compressed(&mut ibe_pp_bytes).unwrap(); - // we need to get the PublicKeyGroup element (G2) let genesis_resharing = double_secret.reshare( &vec![w3f_bls::single::PublicKey::( w3f_bls::double::DoublePublicKey::::from_bytes( @@ -602,12 +597,12 @@ mod tests { let mut pok_bytes = Vec::new(); genesis_resharing[0].1.serialize_compressed(&mut pok_bytes).unwrap(); - let expected_valid_public = genesis_resharing[0].0; - // panic!("{:?}", expected_valid_public); - // let etf_id = bls377::Public::from(expected_valid_public); + let t = sp_core::bls::Pair::::from(pair.clone()); + let expected_public_key = t.acss_recover(&pok_bytes, 1).unwrap(); - // let mut res = store.acss_recover(BLS377, &pair.public(), &pok_bytes[..], msg, 1); - // assert!(bls377::Pair::verify(&res.unwrap(), &msg[..], &etf_id)); + let res = store.acss_recover(BLS377, &pair.public(), &pok_bytes[..], msg, 1).unwrap(); + + assert!(bls377::Pair::verify(&res, &msg[..], &o.public())); } #[test]