Add necessary calls to set_embedded_elliptic_curve_key in coordinator set rotation tests

This commit is contained in:
Luke Parker
2024-08-15 11:39:23 -04:00
parent 0fe7360ce5
commit 843396fe8f

View File

@@ -3,7 +3,7 @@ use tokio::time::{sleep, Duration};
use ciphersuite::Secp256k1;
use serai_client::{
primitives::{insecure_pair_from_name, NetworkId},
primitives::{EmbeddedEllipticCurve, NetworkId, insecure_pair_from_name},
validator_sets::{
self,
primitives::{Session, ValidatorSet},
@@ -55,6 +55,27 @@ async fn publish_tx(serai: &Serai, tx: &Transaction) -> [u8; 32] {
}
}
#[allow(dead_code)]
async fn set_embedded_elliptic_curve_key(
serai: &Serai,
curve: EmbeddedEllipticCurve,
key: Vec<u8>,
pair: &Pair,
nonce: u32,
) -> [u8; 32] {
// get the call
let tx = serai.sign(
pair,
validator_sets::SeraiValidatorSets::set_embedded_elliptic_curve_key(
curve,
key.try_into().unwrap(),
),
nonce,
0,
);
publish_tx(serai, &tx).await
}
#[allow(dead_code)]
async fn allocate_stake(
serai: &Serai,
@@ -138,7 +159,23 @@ async fn set_rotation_test() {
// allocate now for the last participant so that it is guaranteed to be included into session
// 1 set. This doesn't affect the genesis set at all since that is a predetermined set.
allocate_stake(&serai, network, amount, &pair5, 0).await;
set_embedded_elliptic_curve_key(
&serai,
EmbeddedEllipticCurve::Embedwards25519,
vec![0; 32],
&pair5,
0,
)
.await;
set_embedded_elliptic_curve_key(
&serai,
EmbeddedEllipticCurve::Secq256k1,
vec![0; 33],
&pair5,
1,
)
.await;
allocate_stake(&serai, network, amount, &pair5, 2).await;
// genesis keygen
let _ = key_gen::<Secp256k1>(&mut processors, Session(0)).await;