diff --git a/magicblock-chainlink/src/chainlink/mod.rs b/magicblock-chainlink/src/chainlink/mod.rs index 254b82ea7..7d0fd7795 100644 --- a/magicblock-chainlink/src/chainlink/mod.rs +++ b/magicblock-chainlink/src/chainlink/mod.rs @@ -5,7 +5,7 @@ use errors::ChainlinkResult; use fetch_cloner::FetchCloner; use log::*; use magicblock_core::traits::AccountsBank; -use solana_account::AccountSharedData; +use solana_account::{AccountSharedData, ReadableAccount}; use solana_pubkey::Pubkey; use solana_sdk::{ commitment_config::CommitmentConfig, transaction::SanitizedTransaction, @@ -137,7 +137,11 @@ impl let blacklisted_accounts = blacklisted_accounts(&self.validator_id, &self.faucet_id); let removed = self.accounts_bank.remove_where(|pubkey, account| { - !account.delegated() && !blacklisted_accounts.contains(pubkey) + (!account.delegated() + // This fixes the edge-case of accounts that were in the process of + // being undelegated but never completed while the validator was running + || account.owner().eq(&dlp::id())) + && !blacklisted_accounts.contains(pubkey) }); debug!("Removed {removed} non-delegated accounts"); diff --git a/test-integration/test-chainlink/tests/ix_remote_account_provider.rs b/test-integration/test-chainlink/tests/ix_remote_account_provider.rs index 9fefbe8c6..47534ab03 100644 --- a/test-integration/test-chainlink/tests/ix_remote_account_provider.rs +++ b/test-integration/test-chainlink/tests/ix_remote_account_provider.rs @@ -99,7 +99,6 @@ async fn ixtest_get_existing_account_for_valid_slot() { let pubkey = random_pubkey(); let rpc_client = remote_account_provider.rpc_client(); - airdrop(rpc_client, &pubkey, 1_000_000).await; { // Fetching immediately does not return the account yet @@ -108,6 +107,12 @@ async fn ixtest_get_existing_account_for_valid_slot() { assert!(!remote_account.is_found()); } + // Fetching account after airdrop will add it to validator and create subscription + airdrop(rpc_client, &pubkey, 1_000_000).await; + sleep_ms(500).await; + + // Airdrop again and wait for subscription update to be processed + airdrop(rpc_client, &pubkey, 1_000_000).await; info!("Waiting for subscription update..."); sleep_ms(1_500).await; @@ -118,6 +123,7 @@ async fn ixtest_get_existing_account_for_valid_slot() { remote_account_provider.try_get(pubkey).await.unwrap(); assert!(remote_account.is_found()); assert!(remote_account.slot() >= cs); + assert_eq!(remote_account.fresh_lamports().unwrap(), 2_000_000); } } diff --git a/test-integration/test-cloning/tests/01_program-deploy.rs b/test-integration/test-cloning/tests/01_program-deploy.rs index 40e8c85b1..9ac56f282 100644 --- a/test-integration/test-cloning/tests/01_program-deploy.rs +++ b/test-integration/test-cloning/tests/01_program-deploy.rs @@ -178,12 +178,12 @@ async fn test_clone_mini_v4_loader_program_and_upgrade() { ) .await; - const MAX_RETRIES: usize = 20; + const MAX_RETRIES: usize = 50; let mut remaining_retries = MAX_RETRIES; loop { ctx.wait_for_delta_slot_ephem(5).unwrap(); - let bump = remaining_retries - MAX_RETRIES + 1; + let bump = (remaining_retries - MAX_RETRIES) + 1; let msg = format!("Hola Mundo {bump}"); let ix = sdk.log_msg_instruction(&payer.pubkey(), &msg); let (sig, found) = ctx