Integration tests for stake API (#4811)

* more tests for rewards redemption

* break circular deps

* code review
This commit is contained in:
Pankaj Garg
2019-06-25 23:00:35 -07:00
committed by GitHub
parent 1f950781c2
commit 30592f2b12
6 changed files with 291 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ impl Stake {
return 0;
}
// curr slot | 0 | 1 | 2 ... | 100 | 101 | 102 | 103
// curr epoch | 0 | 1 | 2 ... | 100 | 101 | 102 | 103
// action | activate | de-activate | |
// | | | | | | | | |
// | v | | | v | | |
@@ -303,10 +303,10 @@ impl<'a> StakeAccount for KeyedAccount<'a> {
return Err(InstructionError::InsufficientFunds);
}
self.account.lamports -= lamports;
to.account.lamports += lamports;
// Adjust the stake (in case balance dropped below stake)
stake.stake = cmp::min(stake.stake, self.account.lamports);
to.account.lamports += lamports;
Ok(())
self.set_state(&StakeState::Stake(stake))
}
StakeState::Uninitialized => {
if lamports > self.account.lamports {