From 76cf32ba69b904ab3af2444ecab509ad57c8e48e Mon Sep 17 00:00:00 2001 From: Vladimir Babin Date: Wed, 10 Jan 2024 14:09:07 +0300 Subject: [PATCH] Test for negative delegate vesting shares (#22) --- README.md | 7 +++++-- tests/test_exceptions.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4dd409b..b2a5b6d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python Library for [VIZ](https://github.com/VIZ-Blockchain) -![tests](https://github.com/VIZ-Blockchain/viz-python-lib/workflows/tests/badge.svg) +![Tests Status](https://github.com/VIZ-Blockchain/viz-python-lib/actions/workflows/tests.yml/badge.svg) [![Documentation Status](https://readthedocs.org/projects/viz-python-lib/badge/?version=latest)](https://viz-python-lib.readthedocs.io/en/latest/?badge=latest) **This library is in alpha state, API unstable** @@ -27,7 +27,8 @@ Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries brew install openssl ``` -and then use the following commands +and then use the following commands: + ```sh export CFLAGS="-I$(brew --prefix openssl)/include" export LDFLAGS="-L$(brew --prefix openssl)/lib" @@ -53,6 +54,7 @@ poetry install ## Usage Basic read query example: + ```python from viz import Client from pprint import pprint @@ -64,6 +66,7 @@ pprint(viz.info()) ``` Direct RPC calls: + ```python viz.rpc.some_rpc_method() ``` diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 9a5132f..cb77f04 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -39,6 +39,11 @@ def test_negative_withdraw(viz): viz.withdraw_vesting(-10, account="alice") +def test_negative_delegate_vesting_shares(viz): + with pytest.raises(UnhandledRPCError, match='vesting_shares.amount >= 0: Delegation cannot be negative'): + viz.delegate_vesting_shares(delegator='alice', delegatee='bob', amount=-10) + + def test_too_much_beneficiaries(viz, default_account): beneficiaries = [{"account": default_account, "weight": 50}] * 256