pub fn warp_to_slot(&mut self, warp_slot: Slot) -> Result<(), ProgramTestError> {
        let mut bank_forks = self.bank_forks.write().unwrap();
        let bank = bank_forks.working_bank();

        // Force ticks until a new blockhash, otherwise retried transactions will have
        // the same signature
        let last_blockhash = bank.last_blockhash();
        while last_blockhash == bank.last_blockhash() {
            bank.register_tick(&Hash::new_unique());
        }

        // warp ahead to one slot *before* the desired slot because the warped
        // bank is frozen
        let working_slot = bank.slot();
        if warp_slot <= working_slot {
            return Err(ProgramTestError::InvalidWarpSlot);
        }

        let pre_warp_slot = warp_slot - 1;
        let warp_bank = bank_forks.insert(Bank::warp_from_parent(
            &bank,
            &Pubkey::default(),
            pre_warp_slot,
        ));
        bank_forks.set_root(
            pre_warp_slot,
            &solana_runtime::accounts_background_service::AbsRequestSender::default(),
            Some(pre_warp_slot),
        );

        // warp bank is frozen, so go forward one slot from it
        bank_forks.insert(Bank::new_from_parent(
            &warp_bank,
            &Pubkey::default(),
            warp_slot,
        ));

        // Update block commitment cache, otherwise banks server will poll at
        // the wrong slot
        let mut w_block_commitment_cache = self.block_commitment_cache.write().unwrap();
        // HACK: The root set here should be `pre_warp_slot`, but since we're
        // in a testing environment, the root bank never updates after a warp.
        // The ticking thread only updates the working bank, and never the root
        // bank.
        w_block_commitment_cache.set_all_slots(warp_slot, warp_slot);

        let bank = bank_forks.working_bank();
        self.last_blockhash = bank.last_blockhash();
        Ok(())
    }
/// Force the working bank ahead to a new slot
Force the working bank ahead to a new slot
Force the working bank ahead to a new slot
pub fn warp_to_slot(&mut self, warp_slot: Slot) -> Result<(), ProgramTestError> {
        let mut bank_forks = self.bank_forks.write().unwrap();
        let bank = bank_forks.working_bank();
        // Force ticks until a new blockhash, otherwise retried transactions will have
        // the same signature
        let last_blockhash = bank.last_blockhash();
        while last_blockhash == bank.last_blockhash() {
            bank.register_tick(&Hash::new_unique());
        }
        // warp ahead to one slot *before* the desired slot because the warped
        // bank is frozen
        let working_slot = bank.slot();
        if warp_slot <= working_slot {
            return Err(ProgramTestError::InvalidWarpSlot);
        }
        let pre_warp_slot = warp_slot - 1;
        let warp_bank = bank_forks.insert(Bank::warp_from_parent(
            &bank,
            &Pubkey::default(),
            pre_warp_slot,
        ));
        bank_forks.set_root(
            pre_warp_slot,
            &solana_runtime::accounts_background_service::AbsRequestSender::default(),
            Some(pre_warp_slot),
        );
        // warp bank is frozen, so go forward one slot from it
        bank_forks.insert(Bank::new_from_parent(
            &warp_bank,
            &Pubkey::default(),
            warp_slot,
        ));
        // Update block commitment cache, otherwise banks server will poll at
        // the wrong slot
        let mut w_block_commitment_cache = self.block_commitment_cache.write().unwrap();
        // HACK: The root set here should be `pre_warp_slot`, but since we're
        // in a testing environment, the root bank never updates after a warp.
        // The ticking thread only updates the working bank, and never the root
        // bank.
        w_block_commitment_cache.set_all_slots(warp_slot, warp_slot);
        let bank = bank_forks.working_bank();
        self.last_blockhash = bank.last_blockhash();
        Ok(())
    }
pub fn warp_to_slot ( & mut self , warp_slot : Slot ) -> Result < ( ) , ProgramTestError > { let mut bank_forks = self . bank_forks . write ( ) . unwrap ( ) ; let bank = bank_forks . working_bank ( ) ; // Force ticks until a new blockhash, otherwise retried transactions will have // the same signature let last_blockhash = bank . last_blockhash ( ) ; while last_blockhash == bank . last_blockhash ( ) { bank . register_tick ( & Hash :: new_unique ( ) ) ; } // warp ahead to one slot *before* the desired slot because the warped // bank is frozen let working_slot = bank . slot ( ) ; if warp_slot <= working_slot { return Err ( ProgramTestError :: InvalidWarpSlot ) ; } let pre_warp_slot = warp_slot - 1 ; let warp_bank = bank_forks . insert ( Bank :: warp_from_parent ( & bank , & Pubkey :: default ( ) , pre_warp_slot , ) ) ; bank_forks . set_root ( pre_warp_slot , & solana_runtime :: accounts_background_service :: AbsRequestSender :: default ( ) , Some ( pre_warp_slot ) , ) ; // warp bank is frozen, so go forward one slot from it bank_forks . insert ( Bank :: new_from_parent ( & warp_bank , & Pubkey :: default ( ) , warp_slot , ) ) ; // Update block commitment cache, otherwise banks server will poll at // the wrong slot let mut w_block_commitment_cache = self . block_commitment_cache . write ( ) . unwrap ( ) ; // HACK: The root set here should be `pre_warp_slot`, but since we're // in a testing environment, the root bank never updates after a warp. // The ticking thread only updates the working bank, and never the root // bank. w_block_commitment_cache . set_all_slots ( warp_slot , warp_slot ) ; let bank = bank_forks . working_bank ( ) ; self . last_blockhash = bank . last_blockhash ( ) ; Ok ( ( ) ) }
Force the working bank ahead to a new slot
Force the working bank ahead to a new slot
&mut self
warp_slot
Slot