mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Further expand clippy workspace lints
Achieves a notable amount of reduced async and clones.
This commit is contained in:
@@ -23,8 +23,8 @@ use messages::{
|
||||
};
|
||||
use crate::batch_signer::BatchSigner;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_batch_signer() {
|
||||
#[test]
|
||||
fn test_batch_signer() {
|
||||
let keys = key_gen::<_, Ristretto>(&mut OsRng);
|
||||
|
||||
let participant_one = Participant::new(1).unwrap();
|
||||
@@ -74,7 +74,7 @@ async fn test_batch_signer() {
|
||||
let mut db = MemDb::new();
|
||||
|
||||
let mut txn = db.txn();
|
||||
match signer.sign(&mut txn, batch.clone()).await.unwrap() {
|
||||
match signer.sign(&mut txn, batch.clone()).unwrap() {
|
||||
// All participants should emit a preprocess
|
||||
coordinator::ProcessorMessage::BatchPreprocess {
|
||||
id,
|
||||
@@ -109,7 +109,6 @@ async fn test_batch_signer() {
|
||||
preprocesses: clone_without(&preprocesses, i),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
ProcessorMessage::Coordinator(coordinator::ProcessorMessage::SubstrateShare {
|
||||
@@ -137,7 +136,6 @@ async fn test_batch_signer() {
|
||||
shares: clone_without(&shares, i),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
ProcessorMessage::Substrate(substrate::ProcessorMessage::SignedBatch {
|
||||
|
||||
@@ -18,8 +18,8 @@ use serai_client::{primitives::*, validator_sets::primitives::Session};
|
||||
use messages::coordinator::*;
|
||||
use crate::cosigner::Cosigner;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_cosigner() {
|
||||
#[test]
|
||||
fn test_cosigner() {
|
||||
let keys = key_gen::<_, Ristretto>(&mut OsRng);
|
||||
|
||||
let participant_one = Participant::new(1).unwrap();
|
||||
@@ -88,7 +88,6 @@ async fn test_cosigner() {
|
||||
preprocesses: clone_without(&preprocesses, i),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
ProcessorMessage::SubstrateShare { id, shares: mut these_shares } => {
|
||||
@@ -113,7 +112,6 @@ async fn test_cosigner() {
|
||||
shares: clone_without(&shares, i),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
ProcessorMessage::CosignedBlock { block_number, block: signed_block, signature } => {
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::{
|
||||
|
||||
const ID: KeyGenId = KeyGenId { session: Session(1), attempt: 3 };
|
||||
|
||||
pub async fn test_key_gen<N: Network>() {
|
||||
pub fn test_key_gen<N: Network>() {
|
||||
let mut entropies = HashMap::new();
|
||||
let mut dbs = HashMap::new();
|
||||
let mut key_gens = HashMap::new();
|
||||
@@ -37,18 +37,15 @@ pub async fn test_key_gen<N: Network>() {
|
||||
for i in 1 ..= 5 {
|
||||
let key_gen = key_gens.get_mut(&i).unwrap();
|
||||
let mut txn = dbs.get_mut(&i).unwrap().txn();
|
||||
if let ProcessorMessage::Commitments { id, mut commitments } = key_gen
|
||||
.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::GenerateKey {
|
||||
id: ID,
|
||||
params: ThresholdParams::new(3, 5, Participant::new(u16::try_from(i).unwrap()).unwrap())
|
||||
.unwrap(),
|
||||
shares: 1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
if let ProcessorMessage::Commitments { id, mut commitments } = key_gen.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::GenerateKey {
|
||||
id: ID,
|
||||
params: ThresholdParams::new(3, 5, Participant::new(u16::try_from(i).unwrap()).unwrap())
|
||||
.unwrap(),
|
||||
shares: 1,
|
||||
},
|
||||
) {
|
||||
assert_eq!(id, ID);
|
||||
assert_eq!(commitments.len(), 1);
|
||||
all_commitments
|
||||
@@ -74,16 +71,10 @@ pub async fn test_key_gen<N: Network>() {
|
||||
let key_gen = key_gens.get_mut(&i).unwrap();
|
||||
let mut txn = dbs.get_mut(&i).unwrap().txn();
|
||||
let i = Participant::new(u16::try_from(i).unwrap()).unwrap();
|
||||
if let ProcessorMessage::Shares { id, mut shares } = key_gen
|
||||
.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::Commitments {
|
||||
id: ID,
|
||||
commitments: clone_without(&all_commitments, &i),
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
if let ProcessorMessage::Shares { id, mut shares } = key_gen.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::Commitments { id: ID, commitments: clone_without(&all_commitments, &i) },
|
||||
) {
|
||||
assert_eq!(id, ID);
|
||||
assert_eq!(shares.len(), 1);
|
||||
all_shares.insert(i, shares.swap_remove(0));
|
||||
@@ -102,19 +93,16 @@ pub async fn test_key_gen<N: Network>() {
|
||||
let key_gen = key_gens.get_mut(&i).unwrap();
|
||||
let mut txn = dbs.get_mut(&i).unwrap().txn();
|
||||
let i = Participant::new(u16::try_from(i).unwrap()).unwrap();
|
||||
if let ProcessorMessage::GeneratedKeyPair { id, substrate_key, network_key } = key_gen
|
||||
.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::Shares {
|
||||
id: ID,
|
||||
shares: vec![all_shares
|
||||
.iter()
|
||||
.filter_map(|(l, shares)| if i == *l { None } else { Some((*l, shares[&i].clone())) })
|
||||
.collect()],
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
if let ProcessorMessage::GeneratedKeyPair { id, substrate_key, network_key } = key_gen.handle(
|
||||
&mut txn,
|
||||
CoordinatorMessage::Shares {
|
||||
id: ID,
|
||||
shares: vec![all_shares
|
||||
.iter()
|
||||
.filter_map(|(l, shares)| if i == *l { None } else { Some((*l, shares[&i].clone())) })
|
||||
.collect()],
|
||||
},
|
||||
) {
|
||||
assert_eq!(id, ID);
|
||||
if res.is_none() {
|
||||
res = Some((substrate_key, network_key.clone()));
|
||||
@@ -134,13 +122,11 @@ pub async fn test_key_gen<N: Network>() {
|
||||
for i in 1 ..= 5 {
|
||||
let key_gen = key_gens.get_mut(&i).unwrap();
|
||||
let mut txn = dbs.get_mut(&i).unwrap().txn();
|
||||
let KeyConfirmed { mut substrate_keys, mut network_keys } = key_gen
|
||||
.confirm(
|
||||
&mut txn,
|
||||
ID.session,
|
||||
KeyPair(sr25519::Public(res.0), res.1.clone().try_into().unwrap()),
|
||||
)
|
||||
.await;
|
||||
let KeyConfirmed { mut substrate_keys, mut network_keys } = key_gen.confirm(
|
||||
&mut txn,
|
||||
ID.session,
|
||||
&KeyPair(sr25519::Public(res.0), res.1.clone().try_into().unwrap()),
|
||||
);
|
||||
txn.commit();
|
||||
|
||||
assert_eq!(substrate_keys.len(), 1);
|
||||
|
||||
@@ -46,7 +46,7 @@ macro_rules! test_network {
|
||||
#[tokio::test]
|
||||
async fn $key_gen() {
|
||||
init_logger();
|
||||
test_key_gen::<$N>().await;
|
||||
test_key_gen::<$N>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -72,7 +72,7 @@ pub async fn sign<N: Network>(
|
||||
match signers
|
||||
.get_mut(&i)
|
||||
.unwrap()
|
||||
.sign_transaction(&mut txn, actual_id.id, tx, eventuality)
|
||||
.sign_transaction(&mut txn, actual_id.id, tx, &eventuality)
|
||||
.await
|
||||
{
|
||||
// All participants should emit a preprocess
|
||||
|
||||
Reference in New Issue
Block a user