Skip to content

Commit 2a931c3

Browse files
committed
pod conversion tests
1 parent 5b80250 commit 2a931c3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

epoch-rewards/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,30 @@ mod tests {
127127
let mut epoch_rewards = EpochRewards::new(100, 0, 64);
128128
epoch_rewards.distribute(200);
129129
}
130+
131+
#[test]
132+
fn test_pod_epoch_rewards_conversion() {
133+
let pod = PodEpochRewards {
134+
distribution_starting_block_height: 42u64.to_le_bytes(),
135+
num_partitions: 7u64.to_le_bytes(),
136+
parent_blockhash: [0xAA; 32],
137+
total_points: 1234567890u128.to_le_bytes(),
138+
total_rewards: 100u64.to_le_bytes(),
139+
distributed_rewards: 10u64.to_le_bytes(),
140+
active: 1,
141+
};
142+
143+
let epoch_rewards = EpochRewards::from(pod);
144+
145+
assert_eq!(epoch_rewards.distribution_starting_block_height, 42);
146+
assert_eq!(epoch_rewards.num_partitions, 7);
147+
assert_eq!(
148+
epoch_rewards.parent_blockhash,
149+
Hash::new_from_array([0xAA; 32])
150+
);
151+
assert_eq!(epoch_rewards.total_points, 1234567890);
152+
assert_eq!(epoch_rewards.total_rewards, 100);
153+
assert_eq!(epoch_rewards.distributed_rewards, 10);
154+
assert!(epoch_rewards.active);
155+
}
130156
}

epoch-schedule/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,23 @@ mod tests {
311311
let cloned_epoch_schedule = epoch_schedule.clone();
312312
assert_eq!(cloned_epoch_schedule, epoch_schedule);
313313
}
314+
315+
#[test]
316+
fn test_pod_epoch_schedule_conversion() {
317+
let pod = PodEpochSchedule {
318+
slots_per_epoch: 432000u64.to_le_bytes(),
319+
leader_schedule_slot_offset: 432000u64.to_le_bytes(),
320+
warmup: 1,
321+
first_normal_epoch: 14u64.to_le_bytes(),
322+
first_normal_slot: 524256u64.to_le_bytes(),
323+
};
324+
325+
let epoch_schedule = EpochSchedule::from(pod);
326+
327+
assert_eq!(epoch_schedule.slots_per_epoch, 432000);
328+
assert_eq!(epoch_schedule.leader_schedule_slot_offset, 432000);
329+
assert!(epoch_schedule.warmup);
330+
assert_eq!(epoch_schedule.first_normal_epoch, 14);
331+
assert_eq!(epoch_schedule.first_normal_slot, 524256);
332+
}
314333
}

0 commit comments

Comments
 (0)