Skip to content

Commit

Permalink
Merge pull request #706 from onekey-sec/fix-ubi-handler
Browse files Browse the repository at this point in the history
fix(handler): fix UBI PEB size calculation.
  • Loading branch information
qkaiser authored Jan 22, 2024
2 parents c907b42 + bb9cf0a commit 4b1ce6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tests/test_iter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
@pytest.mark.parametrize(
"values, expected",
[
([], set()),
([0, 0], {0}),
([0, 0, 0], {0}),
([1, 2, 3], {1}),
([1, 5, 8, 8, 10, 15], {4, 3, 0, 2, 5}),
([], []),
([0, 0], [0]),
([0, 0, 0], [0, 0]),
([1, 2, 3], [1, 1]),
([1, 5, 8, 8, 10, 15], [4, 3, 0, 2, 5]),
],
)
def test_get_internals(values, expected):
Expand Down
8 changes: 4 additions & 4 deletions unblob/iter_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import itertools
from typing import List, Set
from typing import List


def pairwise(iterable):
Expand All @@ -10,7 +10,7 @@ def pairwise(iterable):
return zip(a, b)


def get_intervals(values: List[int]) -> Set[int]:
def get_intervals(values: List[int]) -> List[int]:
"""Get all the intervals between numbers.
It's similar to numpy.diff function.
Expand All @@ -20,7 +20,7 @@ def get_intervals(values: List[int]) -> Set[int]:
>>> get_intervals([1, 4, 5, 6, 10])
[3, 1, 1, 4]
"""
all_diffs = set()
all_diffs = []
for value, next_value in pairwise(values):
all_diffs.add(next_value - value)
all_diffs.append(next_value - value)
return all_diffs

0 comments on commit 4b1ce6c

Please sign in to comment.