Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Sep 21, 2023
1 parent 660ea02 commit c35529f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4033,39 +4033,39 @@ mod tests {
// when `enable_heap_size_round_up` not enabled:
{
// assert less than 32K heap should cost zero unit
assert_eq!(0, calculate_heap_cost(31_u64 * 1024, heap_cost, false));
assert_eq!(0, calculate_heap_cost(31_u32 * 1024, heap_cost, false));

// assert exact 32K heap should be cost zero unit
assert_eq!(0, calculate_heap_cost(32_u64 * 1024, heap_cost, false));
assert_eq!(0, calculate_heap_cost(32_u32 * 1024, heap_cost, false));

// assert slightly more than 32K heap is mistakenly cost zero unit
assert_eq!(0, calculate_heap_cost(33_u64 * 1024, heap_cost, false));
assert_eq!(0, calculate_heap_cost(33_u32 * 1024, heap_cost, false));

// assert exact 64K heap should cost 1 * heap_cost
assert_eq!(
heap_cost,
calculate_heap_cost(64_u64 * 1024, heap_cost, false)
calculate_heap_cost(64_u32 * 1024, heap_cost, false)
);
}

// when `enable_heap_size_round_up` is enabled:
{
// assert less than 32K heap should cost zero unit
assert_eq!(0, calculate_heap_cost(31_u64 * 1024, heap_cost, true));
assert_eq!(0, calculate_heap_cost(31_u32 * 1024, heap_cost, true));

// assert exact 32K heap should be cost zero unit
assert_eq!(0, calculate_heap_cost(32_u64 * 1024, heap_cost, true));
assert_eq!(0, calculate_heap_cost(32_u32 * 1024, heap_cost, true));

// assert slightly more than 32K heap should cost 1 * heap_cost
assert_eq!(
heap_cost,
calculate_heap_cost(33_u64 * 1024, heap_cost, true)
calculate_heap_cost(33_u32 * 1024, heap_cost, true)
);

// assert exact 64K heap should cost 1 * heap_cost
assert_eq!(
heap_cost,
calculate_heap_cost(64_u64 * 1024, heap_cost, true)
calculate_heap_cost(64_u32 * 1024, heap_cost, true)
);
}
}
Expand Down

0 comments on commit c35529f

Please sign in to comment.