Skip to content

Commit

Permalink
make it clear that objects are equal before clone
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed May 16, 2024
1 parent 15d46c2 commit beed36f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3574,15 +3574,14 @@ mod tests {
);
result.unwrap();

// clone is to zero the alignment padding
let epochschedule_from_buf =
bincode::deserialize::<EpochSchedule>(&got_epochschedule_buf)
.unwrap()
.clone();
bincode::deserialize::<EpochSchedule>(&got_epochschedule_buf).unwrap();

assert_eq!(epochschedule_from_buf, src_epochschedule);

// clone is to zero the alignment padding
assert!(are_bytes_equal(
&epochschedule_from_buf,
&epochschedule_from_buf.clone(),
&clean_epochschedule
));
}
Expand Down Expand Up @@ -3670,11 +3669,12 @@ mod tests {
);
result.unwrap();

// clone is to zero the alignment padding
let rent_from_buf = bincode::deserialize::<Rent>(&got_rent_buf).unwrap().clone();
let rent_from_buf = bincode::deserialize::<Rent>(&got_rent_buf).unwrap();

assert_eq!(rent_from_buf, src_rent);
assert!(are_bytes_equal(&rent_from_buf, &clean_rent));

// clone is to zero the alignment padding
assert!(are_bytes_equal(&rent_from_buf.clone(), &clean_rent));
}

// Test epoch rewards sysvar
Expand Down Expand Up @@ -3734,13 +3734,12 @@ mod tests {
);
result.unwrap();

// clone is to zero the alignment padding
let rewards_from_buf = bincode::deserialize::<EpochRewards>(&got_rewards_buf)
.unwrap()
.clone();
let rewards_from_buf = bincode::deserialize::<EpochRewards>(&got_rewards_buf).unwrap();

assert_eq!(rewards_from_buf, src_rewards);
assert!(are_bytes_equal(&rewards_from_buf, &clean_rewards));

// clone is to zero the alignment padding
assert!(are_bytes_equal(&rewards_from_buf.clone(), &clean_rewards));
}

// Test last restart slot sysvar
Expand Down

0 comments on commit beed36f

Please sign in to comment.