Fix timestamp overflow (#7886)
* Split timestamp calculation into separate fn for math unit testing * Add failing test * Fix failing test; also bump stakes to near expected cluster max supply * Don't error on timestamp of slot 0
This commit is contained in:
@ -404,7 +404,8 @@ impl VoteState {
|
||||
) -> Result<(), VoteError> {
|
||||
if (slot < self.last_timestamp.slot || timestamp < self.last_timestamp.timestamp)
|
||||
|| ((slot == self.last_timestamp.slot || timestamp == self.last_timestamp.timestamp)
|
||||
&& BlockTimestamp { slot, timestamp } != self.last_timestamp)
|
||||
&& BlockTimestamp { slot, timestamp } != self.last_timestamp
|
||||
&& self.last_timestamp.slot != 0)
|
||||
{
|
||||
return Err(VoteError::TimestampTooOld);
|
||||
}
|
||||
@ -1403,5 +1404,9 @@ mod tests {
|
||||
timestamp: timestamp + 1
|
||||
}
|
||||
);
|
||||
|
||||
// Test initial vote
|
||||
vote_state.last_timestamp = BlockTimestamp::default();
|
||||
assert_eq!(vote_state.process_timestamp(0, timestamp), Ok(()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user