Skip to content
Snippets Groups Projects
Commit b60936de authored by Moul's avatar Moul
Browse files

Do not display monetary mass per members

when there is zero members which causes a ZeroDivisionError
G1-test reaching zero members revealed a bug
parent 0b7b088d
No related branches found
No related tags found
No related merge requests found
Pipeline #32949 failed
......@@ -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,6 +112,7 @@ def show_amount_from_pubkey(label: str, inputs_balance: List[int]) -> None:
ud_value,
currency_symbol,
)
if average:
display.append(
[
"Total relative to M/N",
......@@ -124,6 +125,10 @@ def show_amount_from_pubkey(label: str, inputs_balance: List[int]) -> None:
click.echo(table.draw())
def get_average() -> int:
def get_average() -> Optional[int]:
head = get_head_block()
try:
return head["monetaryMass"] / head["membersCount"]
except ZeroDivisionError:
print("The currency reached zero members")
return None
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment