Add tests for vote_program

This commit is contained in:
Greg Fitzgerald
2019-01-21 15:45:30 -08:00
parent c84b796e17
commit d666ebc558
2 changed files with 142 additions and 45 deletions

View File

@ -29,6 +29,12 @@ pub struct Vote {
pub tick_height: u64,
}
impl Vote {
pub fn new(tick_height: u64) -> Self {
Self { tick_height }
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum VoteInstruction {
/// Register a new "vote account" to represent a particular validator in the Vote Contract,
@ -55,6 +61,11 @@ pub fn get_max_size() -> usize {
}
impl VoteProgram {
pub fn new(node_id: Pubkey) -> Self {
let votes = VecDeque::new();
Self { votes, node_id }
}
pub fn deserialize(input: &[u8]) -> Result<VoteProgram, ProgramError> {
deserialize(input).map_err(|_| ProgramError::InvalidUserdata)
}