Skip to content

Commit

Permalink
fix: page offset error [APE-989] (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu authored Jun 13, 2023
1 parent fd5d0ee commit d4fcdd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ape_ledger/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_user_selected_account(self) -> Tuple[str, HDAccountPath]:

address = self._get_user_selection()

account_id = self._choice_index
account_id = self._choice_index + self._index_offset
return address, self._hd_root_path.get_account_path(account_id)

def _get_user_selection(self) -> str:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class TestAddressPromptChoice:
def test_get_user_selected_account(self, mocker, mock_ethereum_app):
mock_prompt = mocker.patch("ape_ledger.choices.click.prompt")
choices = AddressPromptChoice(mock_ethereum_app)
choices._choice_index = 1
choices._choice_index = 3
choices._index_offset = 2

# `None` means the user hasn't selected yeet
# And is entering other keys, possible the paging keys.
Expand All @@ -19,4 +20,4 @@ def _side_effect(*args, **kwargs):
mock_prompt.side_effect = _side_effect
address, hdpath = choices.get_user_selected_account()
assert address == TEST_ADDRESS
assert str(hdpath) == "m/44'/60'/1'/0/0"
assert str(hdpath) == f"m/44'/60'/{choices._choice_index + choices._index_offset}'/0/0"

0 comments on commit d4fcdd5

Please sign in to comment.