Skip to content

Commit d458eea

Browse files
authored
Test for delegate vesting shares (#21)
* Add workflow conditions * Temporary change id-token to permissions * Add test for delegate_vesting_shares * Bump version to 1.0.2
1 parent 867c2cd commit d458eea

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
We follow [Semantic Versions](https://semver.org/).
44

5+
## Version 1.0.2
6+
7+
- Add `delegate_vesting_shares` method
8+
59
## Version 1.0.1
610

711
- Support Python 3.12
@@ -14,4 +18,4 @@ We follow [Semantic Versions](https://semver.org/).
1418

1519
## Version 0.1.0
1620

17-
- Initial release
21+
- Initial release

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "viz-python-lib"
7-
version = "1.0.1"
7+
version = "1.0.2"
88
description = "Python library for VIZ blockchain"
99
authors = ["Vladimir Kamarzin <[email protected]>"]
1010
license = "MIT"

tests/test_viz.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def test_proposal_update(viz, default_account):
3333

3434

3535
def test_transfer(viz, default_account):
36-
3736
trx = viz.transfer("null", 1, "VIZ", memo="test_viz", account=default_account)
3837
assert isinstance(trx, dict)
3938
viz.transfer(default_account, 1, "VIZ", memo="#encrypted memo", account=default_account)
@@ -52,7 +51,14 @@ def test_fixed_award(viz, default_account):
5251
viz.fixed_award(default_account, reward_amount=10, max_energy=50, memo="test_viz", account=default_account)
5352

5453
beneficiaries = [{"account": default_account, "weight": 50}]
55-
viz.fixed_award(default_account, reward_amount=10, max_energy=50, memo="test_viz", beneficiaries=beneficiaries, account=default_account)
54+
viz.fixed_award(
55+
default_account,
56+
reward_amount=10,
57+
max_energy=50,
58+
memo="test_viz",
59+
beneficiaries=beneficiaries,
60+
account=default_account,
61+
)
5662

5763

5864
def test_custom(viz, default_account):
@@ -132,3 +138,7 @@ def test_create_account(viz):
132138

133139
# referrer
134140
viz.create_account('jimmy8', password='123', creator='alice', referrer='bob')
141+
142+
143+
def test_delegate_vesting_shares(viz):
144+
viz.delegate_vesting_shares(delegator='alice', delegatee='bob', amount=10)

viz/viz.py

+13-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, DefaultDict, Dict, List, Optional, Union
55

66
from graphenecommon.chain import AbstractGrapheneChain
7-
from graphenecommon.exceptions import KeyAlreadyInStoreException,AccountDoesNotExistsException
7+
from graphenecommon.exceptions import KeyAlreadyInStoreException, AccountDoesNotExistsException
88

99
from vizapi.noderpc import NodeRPC
1010
from vizbase import operations
@@ -265,7 +265,7 @@ def award(
265265
)
266266

267267
return self.finalizeOp(op, account, "regular")
268-
268+
269269
def fixed_award(
270270
self,
271271
receiver: str,
@@ -669,13 +669,13 @@ def create_account(
669669
op = operations.Account_create(**op)
670670

671671
return self.finalizeOp(op, creator, "active")
672-
672+
673673
def update_account_profile(
674674
self,
675675
account_name: str,
676676
memo_key: str,
677677
json_meta: Optional[Dict[str, Any]] = None,
678-
) -> dict:
678+
) -> dict:
679679
"""
680680
Update account profile.
681681
@@ -685,7 +685,7 @@ def update_account_profile(
685685
686686
:param str account_name: (**required**) new account name
687687
:param dict json_meta: Optional meta data for the account
688-
688+
689689
:raises AccountDoesNotExistsException: if the account does not exist
690690
"""
691691

@@ -704,19 +704,16 @@ def update_account_profile(
704704
op = operations.Account_update(**op)
705705

706706
return self.finalizeOp(ops=op, account=account_name, permission="active")
707-
708-
def delegate_vesting_shares(
709-
self,
710-
delegator: str,
711-
delegatee: str,
712-
amount: float
713-
) -> dict:
707+
708+
def delegate_vesting_shares(self, delegator: str, delegatee: str, amount: float) -> dict:
714709
"""
715710
Delegate vesting SHARES to account.
716711
717712
:param str delegator: account that delegates
718713
:param str delegatee: account to which is delegated
719714
:param float amount: number of SHARES to be delegated
715+
716+
:raises AccountDoesNotExistsException: if the account does not exist
720717
"""
721718

722719
# check if the account does not exist
@@ -729,10 +726,10 @@ def delegate_vesting_shares(
729726
"delegator": delegator,
730727
"delegatee": delegatee,
731728
"vesting_shares": "{:.{prec}f} {asset}".format(
732-
float(amount),
733-
prec=PRECISIONS.get(self.rpc.chain_params["shares_symbol"]),
734-
asset=self.rpc.chain_params["shares_symbol"],
735-
),
729+
float(amount),
730+
prec=PRECISIONS.get(self.rpc.chain_params["shares_symbol"]),
731+
asset=self.rpc.chain_params["shares_symbol"],
732+
),
736733
}
737734

738735
op = operations.Delegate_vesting_shares(**op)

0 commit comments

Comments
 (0)