Skip to content

Commit 732d1e8

Browse files
committed
tests: rm redundant, clean up bincode gating
1 parent 70cae6a commit 732d1e8

File tree

5 files changed

+12
-37
lines changed

5 files changed

+12
-37
lines changed

sysvar/src/clock.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,18 @@ mod tests {
141141
use {super::*, crate::tests::to_bytes, serial_test::serial};
142142

143143
#[test]
144+
#[cfg(feature = "bincode")]
144145
fn test_clock_size_matches_bincode() {
145146
// Prove that Clock's in-memory layout matches its bincode serialization,
146147
// so we do not need to use sysvar_packed_struct.
147148
let clock = Clock::default();
148149
let in_memory_size = core::mem::size_of::<Clock>();
150+
let bincode_size = bincode::serialized_size(&clock).unwrap() as usize;
149151

150-
#[cfg(feature = "bincode")]
151-
{
152-
let bincode_size = bincode::serialized_size(&clock).unwrap() as usize;
153-
assert_eq!(
154-
in_memory_size, bincode_size,
155-
"Clock in-memory size ({in_memory_size}) must match bincode size ({bincode_size})",
156-
);
157-
}
158-
159-
// Clock is 5 u64s = 40 bytes
160-
assert_eq!(in_memory_size, 40);
152+
assert_eq!(
153+
in_memory_size, bincode_size,
154+
"Clock in-memory size ({in_memory_size}) must match bincode size ({bincode_size})",
155+
);
161156
}
162157

163158
#[test]

sysvar/src/epoch_rewards.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ impl SysvarSerialize for EpochRewards {}
214214
mod tests {
215215
use {super::*, crate::Sysvar, serial_test::serial};
216216

217-
#[test]
218-
fn test_epoch_rewards_packed_size() {
219-
assert_eq!(core::mem::size_of::<EpochRewardsPacked>(), 81);
220-
}
221-
222217
#[test]
223218
#[serial]
224219
#[cfg(feature = "bincode")]

sysvar/src/epoch_schedule.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ impl SysvarSerialize for EpochSchedule {}
173173
mod tests {
174174
use {super::*, crate::Sysvar, serial_test::serial};
175175

176-
#[test]
177-
fn test_epoch_schedule_packed_size() {
178-
assert_eq!(core::mem::size_of::<EpochSchedulePacked>(), 33);
179-
}
180-
181176
#[test]
182177
#[serial]
183178
#[cfg(feature = "bincode")]

sysvar/src/last_restart_slot.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,18 @@ mod tests {
5656
use {super::*, crate::tests::to_bytes, serial_test::serial};
5757

5858
#[test]
59+
#[cfg(feature = "bincode")]
5960
fn test_last_restart_slot_size_matches_bincode() {
6061
// Prove that LastRestartSlot's in-memory layout matches its bincode serialization,
6162
// so we do not need to use sysvar_packed_struct.
6263
let slot = LastRestartSlot::default();
6364
let in_memory_size = core::mem::size_of::<LastRestartSlot>();
65+
let bincode_size = bincode::serialized_size(&slot).unwrap() as usize;
6466

65-
#[cfg(feature = "bincode")]
66-
{
67-
let bincode_size = bincode::serialized_size(&slot).unwrap() as usize;
68-
assert_eq!(
69-
in_memory_size, bincode_size,
70-
"LastRestartSlot in-memory size ({in_memory_size}) must match bincode size ({bincode_size})",
71-
);
72-
}
73-
74-
// LastRestartSlot is 1 u64 = 8 bytes
75-
assert_eq!(in_memory_size, 8);
67+
assert_eq!(
68+
in_memory_size, bincode_size,
69+
"LastRestartSlot in-memory size ({in_memory_size}) must match bincode size ({bincode_size})",
70+
);
7671
}
7772

7873
#[test]

sysvar/src/rent.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ impl SysvarSerialize for Rent {}
169169
mod tests {
170170
use {super::*, crate::Sysvar, serial_test::serial};
171171

172-
#[test]
173-
fn test_rent_packed_size() {
174-
assert_eq!(core::mem::size_of::<RentPacked>(), 17);
175-
}
176-
177172
#[test]
178173
#[serial]
179174
#[cfg(feature = "bincode")]

0 commit comments

Comments
 (0)