diff --git a/integration_tests/tests/fixtures/restaking_client.rs b/integration_tests/tests/fixtures/restaking_client.rs index ab0d6b1..9abc567 100644 --- a/integration_tests/tests/fixtures/restaking_client.rs +++ b/integration_tests/tests/fixtures/restaking_client.rs @@ -36,12 +36,30 @@ pub struct NcnRoot { pub ncn_admin: Keypair, } +impl Clone for NcnRoot { + fn clone(&self) -> Self { + Self { + ncn_pubkey: self.ncn_pubkey, + ncn_admin: self.ncn_admin.insecure_clone(), + } + } +} + #[derive(Debug)] pub struct OperatorRoot { pub operator_pubkey: Pubkey, pub operator_admin: Keypair, } +impl Clone for OperatorRoot { + fn clone(&self) -> Self { + Self { + operator_pubkey: self.operator_pubkey, + operator_admin: self.operator_admin.insecure_clone(), + } + } +} + pub struct RestakingProgramClient { banks_client: BanksClient, payer: Keypair, diff --git a/integration_tests/tests/fixtures/test_builder.rs b/integration_tests/tests/fixtures/test_builder.rs index cf31494..36781c6 100644 --- a/integration_tests/tests/fixtures/test_builder.rs +++ b/integration_tests/tests/fixtures/test_builder.rs @@ -22,13 +22,8 @@ use crate::fixtures::{ }; pub struct ConfiguredVault { - pub vault_program_client: VaultProgramClient, - #[allow(dead_code)] - pub restaking_program_client: RestakingProgramClient, - pub vault_config_admin: Keypair, + pub ncn_root: NcnRoot, pub vault_root: VaultRoot, - #[allow(dead_code)] - pub restaking_config_admin: Keypair, pub operator_roots: Vec, } @@ -131,35 +126,36 @@ impl TestBuilder { pub async fn setup_ncn(&mut self) -> TestResult { let mut restaking_program_client = self.restaking_program_client(); + let mut vault_program_client = self.vault_program_client(); + vault_program_client.do_initialize_config().await?; restaking_program_client.do_initialize_config().await?; let ncn_root = restaking_program_client.do_initialize_ncn().await?; Ok(ncn_root) } - pub async fn add_vault_to_ncn(&mut self, ncn_root: &NcnRoot) { - //TODO start here - } - - /// Configures a vault with an NCN and operators fully configured - pub async fn setup_vault_with_ncn_and_operators( + pub async fn setup_vault( &mut self, - deposit_fee_bps: u16, - withdrawal_fee_bps: u16, - reward_fee_bps: u16, - num_operators: u16, - slasher_amounts: &[u64], + ncn_root: &NcnRoot, + operator_roots: &[OperatorRoot], ) -> TestResult { let mut vault_program_client = self.vault_program_client(); let mut restaking_program_client = self.restaking_program_client(); - let (vault_config_admin, vault_root) = vault_program_client - .setup_config_and_vault(deposit_fee_bps, withdrawal_fee_bps, reward_fee_bps) + const DEPOSIT_FEE_BPS: u16 = 10; + const WITHDRAWAL_FEE_BPS: u16 = 10; + const REWARD_FEE_BPS: u16 = 10; + + let vault_root = vault_program_client + .do_initialize_vault( + DEPOSIT_FEE_BPS, + WITHDRAWAL_FEE_BPS, + REWARD_FEE_BPS, + 9, + &self.context.payer.pubkey(), + ) .await?; - let restaking_config_admin = restaking_program_client.do_initialize_config().await?; - - let ncn_root = restaking_program_client.do_initialize_ncn().await?; // vault <> ncn restaking_program_client @@ -177,10 +173,7 @@ impl TestBuilder { .do_warmup_vault_ncn_ticket(&vault_root, &ncn_root.ncn_pubkey) .await?; - let mut operator_roots = Vec::with_capacity(num_operators as usize); - for _ in 0..num_operators { - let operator_root = restaking_program_client.do_initialize_operator().await?; - + for operator_root in operator_roots { // ncn <> operator restaking_program_client .do_initialize_ncn_operator_state(&ncn_root, &operator_root.operator_pubkey) @@ -207,58 +200,12 @@ impl TestBuilder { &operator_root.operator_pubkey, ) .await?; - - operator_roots.push(operator_root); - } - - let mut slashers_amounts: Vec<(Keypair, u64)> = Vec::with_capacity(slasher_amounts.len()); - for amount in slasher_amounts { - let slasher = Keypair::new(); - self.transfer(&slasher.pubkey(), 10.0).await?; - - restaking_program_client - .do_initialize_ncn_vault_slasher_ticket( - &ncn_root, - &vault_root.vault_pubkey, - &slasher.pubkey(), - *amount, - ) - .await?; - self.warp_slot_incremental(1).await.unwrap(); - restaking_program_client - .do_warmup_ncn_vault_slasher_ticket( - &ncn_root, - &vault_root.vault_pubkey, - &slasher.pubkey(), - ) - .await?; - - vault_program_client - .do_initialize_vault_ncn_slasher_ticket( - &vault_root, - &ncn_root.ncn_pubkey, - &slasher.pubkey(), - ) - .await?; - self.warp_slot_incremental(1).await.unwrap(); - vault_program_client - .do_warmup_vault_ncn_slasher_ticket( - &vault_root, - &ncn_root.ncn_pubkey, - &slasher.pubkey(), - ) - .await?; - - slashers_amounts.push((slasher, *amount)); } Ok(ConfiguredVault { - vault_program_client, - restaking_program_client, + ncn_root: ncn_root.clone(), vault_root, - vault_config_admin, - restaking_config_admin, - operator_roots, + operator_roots: operator_roots.to_vec(), }) } } diff --git a/integration_tests/tests/fixtures/vault_client.rs b/integration_tests/tests/fixtures/vault_client.rs index 7f86a88..1103900 100644 --- a/integration_tests/tests/fixtures/vault_client.rs +++ b/integration_tests/tests/fixtures/vault_client.rs @@ -49,6 +49,15 @@ pub struct VaultRoot { pub vault_admin: Keypair, } +impl Clone for VaultRoot { + fn clone(&self) -> Self { + Self { + vault_pubkey: self.vault_pubkey, + vault_admin: self.vault_admin.insecure_clone(), + } + } +} + impl Debug for VaultRoot { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(