Correct comment stating lockup gates stake authorize ixs (#10063)
* Correct old comment stating lockup gates stake authorize ixs * Delete dead stake code
This commit is contained in:
parent
6a6c5f196a
commit
b762319fc5
|
@ -99,14 +99,11 @@ pub enum StakeAuthorize {
|
|||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
pub struct Lockup {
|
||||
/// UnixTimestamp at which this stake will allow withdrawal, or
|
||||
/// changes to authorized staker or withdrawer, unless the
|
||||
/// UnixTimestamp at which this stake will allow withdrawal, unless the
|
||||
/// transaction is signed by the custodian
|
||||
pub unix_timestamp: UnixTimestamp,
|
||||
/// epoch height at which this stake will allow withdrawal, or
|
||||
/// changes to authorized staker or withdrawer, unless the
|
||||
/// epoch height at which this stake will allow withdrawal, unless the
|
||||
/// transaction is signed by the custodian
|
||||
/// to the custodian
|
||||
pub epoch: Epoch,
|
||||
/// custodian signature on a transaction exempts the operation from
|
||||
/// lockup constraints
|
||||
|
@ -153,21 +150,6 @@ impl Meta {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn authorize_withdraw(
|
||||
&mut self,
|
||||
authority: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
clock: &Clock,
|
||||
) -> Result<(), InstructionError> {
|
||||
// verify that lockup has expired or that the authorization
|
||||
// is *also* signed by the custodian
|
||||
if self.lockup.is_in_force(clock, signers) {
|
||||
return Err(StakeError::LockupInForce.into());
|
||||
}
|
||||
self.authorized
|
||||
.authorize(signers, authority, StakeAuthorize::Withdrawer)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
|
@ -949,39 +931,6 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_meta_authorize_withdraw() {
|
||||
let staker = Pubkey::new_rand();
|
||||
let custodian = Pubkey::new_rand();
|
||||
let mut meta = Meta {
|
||||
authorized: Authorized::auto(&staker),
|
||||
lockup: Lockup {
|
||||
epoch: 0,
|
||||
unix_timestamp: 0,
|
||||
custodian,
|
||||
},
|
||||
..Meta::default()
|
||||
};
|
||||
// verify sig check
|
||||
let mut signers = HashSet::new();
|
||||
signers.insert(staker);
|
||||
let mut clock = Clock::default();
|
||||
|
||||
// verify lockup check
|
||||
meta.lockup.epoch = 1;
|
||||
assert_eq!(
|
||||
meta.authorize_withdraw(&staker, &signers, &clock),
|
||||
Err(StakeError::LockupInForce.into())
|
||||
);
|
||||
// verify lockup check defeated by custodian
|
||||
signers.insert(custodian);
|
||||
assert_eq!(meta.authorize_withdraw(&staker, &signers, &clock), Ok(()));
|
||||
// verify lock expiry
|
||||
signers.remove(&custodian);
|
||||
clock.epoch = 1;
|
||||
assert_eq!(meta.authorize_withdraw(&staker, &signers, &clock), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stake_state_stake_from_fail() {
|
||||
let mut stake_account = Account::new(0, std::mem::size_of::<StakeState>(), &id());
|
||||
|
|
Loading…
Reference in New Issue