-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Iterative impl of `explode_gap` * Fmt * Fix lint
- Loading branch information
1 parent
74c03ed
commit c7f570d
Showing
2 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from background_tasks import explode_gap | ||
|
||
|
||
def check_gaps(start_slot, end_slot, sprp): | ||
result = explode_gap(start_slot, end_slot, sprp=sprp) | ||
|
||
assert len(result) > 0 | ||
|
||
prev_end = None | ||
for start, end in result: | ||
assert start < end | ||
assert start == start_slot or (start == prev_end + 1 and start % sprp == 1) | ||
assert end == end_slot or (end < end_slot and end % sprp == 0) | ||
prev_end = end | ||
|
||
|
||
def test_explode_large_gap(): | ||
start_slot = 14273 | ||
end_slot = 7530327 | ||
sprp = 2048 | ||
check_gaps(start_slot, end_slot, sprp) | ||
|
||
|
||
def test_explode_small_gap_unaligned(): | ||
start_slot = 1 | ||
end_slot = 10 | ||
sprp = 2048 | ||
check_gaps(start_slot, end_slot, sprp) | ||
|
||
|
||
def test_explode_small_gap_aligned(): | ||
start_slot = 1 | ||
end_slot = 2048 | ||
sprp = 2048 | ||
check_gaps(start_slot, end_slot, sprp) |