Add unit-test for Rewards program

This commit is contained in:
Greg Fitzgerald
2019-02-13 11:33:39 -07:00
parent 134cd7ab04
commit 2c5cbaff25
8 changed files with 151 additions and 98 deletions

View File

@ -12,6 +12,7 @@ pub mod native_program;
pub mod packet;
pub mod payment_plan;
pub mod pubkey;
pub mod rewards_program;
pub mod shortvec;
pub mod signature;
pub mod storage_program;

View File

@ -0,0 +1,24 @@
use crate::pubkey::Pubkey;
use bincode::serialized_size;
pub const REWARDS_PROGRAM_ID: [u8; 32] = [
133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
];
pub fn check_id(program_id: &Pubkey) -> bool {
program_id.as_ref() == REWARDS_PROGRAM_ID
}
pub fn id() -> Pubkey {
Pubkey::new(&REWARDS_PROGRAM_ID)
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
struct RewardsState {}
/// Upper limit on the size of the Rewards State.
pub fn get_max_size() -> usize {
let rewards_state = RewardsState::default();
serialized_size(&rewards_state).unwrap() as usize
}

View File

@ -20,7 +20,7 @@ pub fn id() -> Pubkey {
}
// Maximum number of votes to keep around
const MAX_VOTE_HISTORY: usize = 32;
pub const MAX_VOTE_HISTORY: usize = 32;
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Vote {