Skip to content

Commit

Permalink
remove trailing None in bet amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Sep 29, 2023
1 parent 707535c commit 217fd04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions neofoodclub/bets.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def bet_amounts(
)
return

# remove trailing None's
while len(val) and val[-1] is None:
val = val[:-1]

# strictly enforcing amount of values provided
if len(val) != self._indices.size:
raise InvalidData(
Expand Down
10 changes: 10 additions & 0 deletions tests/test_bet_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,13 @@ def test_indices_to_bet_hash(
bet_hash: str, bet_indices: Sequence[Sequence[int]]
) -> None:
assert math.bets_hash_value(bet_indices) == bet_hash


def test_bet_with_trailing_none_in_amounts(
nfc: NeoFoodClub,
) -> None:
nine_bets = nfc.make_bets_from_hash(
"abaakaebapkddapudaaqkbaaa", amounts_hash="EmxCoKCoKCglDKUCYqEXkByWBpqzGO"
)
assert len(nine_bets) == 9
assert len(nine_bets.bet_amounts) == 9

0 comments on commit 217fd04

Please sign in to comment.