diff --git a/neofoodclub/bets.py b/neofoodclub/bets.py index 4e87b52..a7f9fcf 100644 --- a/neofoodclub/bets.py +++ b/neofoodclub/bets.py @@ -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( diff --git a/tests/test_bet_functions.py b/tests/test_bet_functions.py index 4fea3f7..d7bcfcc 100644 --- a/tests/test_bet_functions.py +++ b/tests/test_bet_functions.py @@ -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