@@ -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}
0 commit comments