diff --git a/silkaj/money/balance.py b/silkaj/money/balance.py index 4cfa5b6b6621ad1f9644e2c246a4fb68951302f9..a1a1f42ae1f51f1d550a845464aaef421761776c 100644 --- a/silkaj/money/balance.py +++ b/silkaj/money/balance.py @@ -14,7 +14,7 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys -from typing import List +from typing import List, Optional import rich_click as click @@ -112,18 +112,23 @@ def show_amount_from_pubkey(label: str, inputs_balance: List[int]) -> None: ud_value, currency_symbol, ) - display.append( - [ - "Total relative to M/N", - f"{round(totalAmountInput / average, 2)} x M/N", - ], - ) + if average: + display.append( + [ + "Total relative to M/N", + f"{round(totalAmountInput / average, 2)} x M/N", + ], + ) table = tui.Table() table.fill_rows(display) click.echo(table.draw()) -def get_average() -> int: +def get_average() -> Optional[int]: head = get_head_block() - return head["monetaryMass"] / head["membersCount"] + try: + return head["monetaryMass"] / head["membersCount"] + except ZeroDivisionError: + print("The currency reached zero members") + return None diff --git a/tests/integration/test_end_to_end.py b/tests/integration/test_end_to_end.py index a96bb3faf839344f481219c7ac25cb09eca93baf..70ad4d18adf67d76edfc571cda9ef73bf26f6e90 100644 --- a/tests/integration/test_end_to_end.py +++ b/tests/integration/test_end_to_end.py @@ -62,4 +62,3 @@ def test_money_balance(): assert ":EyF" in output assert "│ Total balance (unit|relative) │" in output assert "UD ĞTest" in output - assert "Total relative to M/N" in output