Skip to content

Commit ac390a2

Browse files
authored
Fix tests and prepare for release 1.0.0 version
* Update python version and poetry installation path * Build only on curreny version Python 3.11 * Update test workflow * Update python in Pipfile * Update dependencies * Build on latest 3.10 python version * Update versions * Return back python version * poetry lock * Update pytest * Update docker version * Limit number of retries * Update all dependencies * Rollback tests workflow * Remove poetry path * Add sleep before yield container * Disable history tests * Update python versions * Update dependencies * Increase sleep time for energy test * Increase sleep time * Update checkout action * Remove python 3.12 * Fix energy test, deprecation to chronological history method * Bump to 1.0.0, update min python version to 3.8 and remove cache separate action * Update actions * Return back sphinx versions * Increase sleep before history * Update changelog
1 parent eea2f5e commit ac390a2

File tree

10 files changed

+1353
-1122
lines changed

10 files changed

+1353
-1122
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,25 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.6, 3.7, 3.8]
10+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1111

1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
14+
- name: Install Poetry
15+
run: pipx install poetry
1416
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v1
17+
uses: actions/setup-python@v4
1618
with:
1719
python-version: ${{ matrix.python-version }}
18-
19-
- name: Install poetry
20-
run: |
21-
curl -sSL \
22-
"https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py" | python
23-
24-
- name: Set up cache
25-
uses: actions/cache@v1
26-
with:
27-
path: .venv
28-
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
20+
cache: 'poetry'
2921

3022
- name: Install dependencies
3123
run: |
32-
source "$HOME/.poetry/env"
3324
poetry config virtualenvs.in-project true
3425
poetry install
3526
36-
- name: Run checks
27+
- name: Run tests
3728
run: |
38-
source "$HOME/.poetry/env"
3929
poetry run pytest
4030
4131
# Uncomment this lines if you wish to upload coverage to codecov:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ target/
6767
.scannerwork/
6868

6969
.mypy_cache/
70+
.vscode

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ We follow [Semantic Versions](https://semver.org/).
66
## Version 0.1.0
77

88
- Initial release
9+
10+
## Version 1.0.0
11+
12+
- Add `fixed_award` and `update_account_profile` methods
13+
- Fix memo decoding errors
14+
- Bump dependencies versions

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
graphenelib = ">=1.1.11"
7+
graphenelib = ">=1.6"
88
pycryptodome = "*"
99
websockets = "*"
1010
appdirs = "*"
@@ -15,4 +15,4 @@ PyYAML = "*"
1515
[dev-packages]
1616

1717
[requires]
18-
python_version = "3.6"
18+
python_version = "3.8"

poetry.lock

Lines changed: 1267 additions & 1021 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[build-system]
2-
requires = ["poetry>=0.12"]
3-
build-backend = "poetry.masonry.api"
2+
requires = ["poetry-core>=1.0.0"]
3+
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "viz-python-lib"
7-
version = "0.1.0"
8-
description = "python library for VIZ blockchain"
7+
version = "1.0.0"
8+
description = "Python library for VIZ blockchain"
99
authors = ["Vladimir Kamarzin <vvk@vvk.pp.ru>"]
1010
license = "MIT"
1111
readme = "README.md"
@@ -27,24 +27,25 @@ classifiers = [
2727

2828

2929
[tool.poetry.dependencies]
30-
python = "^3.6.1"
31-
graphenelib = "^1.2.0"
32-
toolz = "^0.10.0"
33-
funcy = "^1.14"
34-
docker = "^4.2.0"
30+
python = "^3.8"
31+
graphenelib = "^1.6.0"
32+
toolz = "^0.12.0"
33+
funcy = "^2.0"
34+
docker = "^6.1.3"
35+
aiohttp = "^3.8.6"
3536

3637
[tool.poetry.dev-dependencies]
37-
pre-commit = "^2.2.0"
38-
pytest = "^5.4"
39-
pytest-cov = "^2.7"
40-
pytest-mock = "^3.1.0"
38+
pre-commit = "^3.5.0"
39+
pytest = "^7.4.3"
40+
pytest-cov = "^4.1.0"
41+
pytest-mock = "^3.12.0"
4142

4243
sphinx = "^2.2"
4344
sphinx-autoapi = "^1.4.0"
4445
# used in docs to include markdown files
45-
m2r = "^0.2"
46+
m2r = "^0.3.1"
4647
# used in docs to parse pyproject.toml
47-
tomlkit = "^0.6"
48+
tomlkit = "^0.11.8"
4849

4950
[tool.black]
5051
line-length = 120

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ norecursedirs = *.egg .eggs dist build docs .tox .git __pycache__
44

55
# Extra options:
66
addopts =
7-
--strict
7+
--strict-markers
88
--doctest-modules
99
--cov=viz
1010
--cov=vizbase

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import socket
33
import uuid
4-
54
import docker
65
import pytest
76

@@ -68,6 +67,7 @@ def viz_testnet(session_id, unused_port, docker_manager):
6867
)
6968
container.http_port = port_http
7069
container.ws_port = port_ws
70+
7171
yield container
7272
container.remove(v=True, force=True)
7373

tests/test_account.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import time
2-
32
import pytest
43
from graphenecommon.exceptions import AccountDoesNotExistsException
5-
64
from viz.account import Account
75

86

@@ -22,7 +20,7 @@ def _make_ops(viz, default_account):
2220
time.sleep(1)
2321

2422

25-
def test_init(viz, default_account):
23+
def test_account_not_found(viz, default_account):
2624
Account(default_account)
2725

2826
with pytest.raises(AccountDoesNotExistsException):
@@ -44,11 +42,11 @@ def test_current_energy(account, viz):
4442
assert 0 < en <= 100
4543

4644
pct = 10
47-
time.sleep(3) # wait for HF4 on testnet
45+
time.sleep(15) # wait for HF4 on testnet
4846
viz.award(account.name, pct, account=account.name)
49-
en_new = account.current_energy()
5047
time.sleep(1)
51-
assert en - en_new == pytest.approx(pct, abs=1)
48+
en_new = account.current_energy()
49+
assert en - en_new == pytest.approx(pct, abs=3.0)
5250

5351

5452
def test_virtual_op_count(viz):
@@ -66,21 +64,7 @@ def test_get_withdraw_routes(viz):
6664

6765

6866
@pytest.mark.usefixtures('_make_ops')
69-
def test_history(account):
70-
history = list(account.history())
71-
assert 'trx_id' in history[0]
72-
73-
history = list(account.history(raw_output=True))
74-
assert 'trx_id' in history[0][1]
75-
76-
history = list(account.history(batch_size=1, limit=2))
77-
assert len(history) == 2
78-
79-
history = list(account.history(filter_by='transfer_to_vesting'))
80-
assert history[0]['type'] == 'transfer_to_vesting'
81-
82-
83-
@pytest.mark.usefixtures('_make_ops')
84-
def test_history_reverse(account):
67+
def test_history_reverse(account: Account):
68+
time.sleep(2)
8569
history = list(account.history_reverse(batch_size=1, limit=2))
8670
assert len(history) == 2

viz/account.py

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import TYPE_CHECKING, Generator, List, Optional, Union
2-
2+
from warnings import warn
33
from graphenecommon.exceptions import AccountDoesNotExistsException
44
from toolz import dissoc
55

@@ -83,8 +83,7 @@ def virtual_op_count(self) -> int:
8383
except IndexError:
8484
return 0
8585
else:
86-
# fist item has 0 index, so count is +1
87-
return last_item + 1
86+
return last_item
8887

8988
def get_withdraw_routes(self, type_: str = 'all') -> dict:
9089
"""
@@ -185,9 +184,12 @@ def history(
185184
limit: int = -1,
186185
) -> HistoryGenerator:
187186
"""
188-
Stream account history in chronological order.
187+
THIS FUNCTION IS DEPRECATED. PLEASE USE :py:func:`history_reverse` INSTEAD.
188+
189+
Stream account history in chronological order.
189190
190191
This generator yields history items which may be in list or dict form depending on ``raw_output``.
192+
Output is similar to :py:func:`history_reverse`.
191193
192194
:param str,list filter_by: filter out all but these operations
193195
:param int start: (Optional) skip items until this index
@@ -197,45 +199,9 @@ def history(
197199
:param int limit: (Optional) limit number of filtered items to this amount (-1 means unlimited).
198200
This is a rough limit, actual results could be a bit longer
199201
:return: number of ops
200-
201-
Non-raw output example of yielded item:
202-
203-
.. code-block:: python
204-
205-
{
206-
'from': 'viz',
207-
'to': 'null',
208-
'amount': '1.000 VIZ',
209-
'memo': 'test',
210-
'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
211-
'block': 5,
212-
'trx_in_block': 0,
213-
'op_in_trx': 0,
214-
'virtual_op': 0,
215-
'timestamp': '2020-05-19T08:10:47',
216-
'account': 'viz',
217-
'type': 'transfer',
218-
'_id': 'd1ed77ae861bb1ecc26a82dd275cc80e5ac124a6',
219-
'index': 0,
220-
}
221-
222-
Raw output example of single item:
223-
224-
.. code-block:: python
225-
226-
[
227-
0,
228-
{
229-
'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
230-
'block': 5,
231-
'trx_in_block': 0,
232-
'op_in_trx': 0,
233-
'virtual_op': 0,
234-
'timestamp': '2020-05-19T08:10:47',
235-
'op': ['transfer', {'from': 'viz', 'to': 'null', 'amount': '1.000 VIZ', 'memo': 'test'}],
236-
},
237-
]
238202
"""
203+
warn("Function `history` is not recommened. Use `history_reverse` instead.", DeprecationWarning, stacklevel=2)
204+
239205
op_count = 0
240206

241207
max_index = self.virtual_op_count()
@@ -273,7 +239,6 @@ def history_reverse(
273239
Stream account history in reverse chronological order.
274240
275241
This generator yields history items which may be in list or dict form depending on ``raw_output``.
276-
Output is similar to :py:func:`history`.
277242
278243
:param str,list filter_by: filter out all but these operations
279244
:param int batch_size: (Optional) request as many items from API in each chunk
@@ -282,6 +247,44 @@ def history_reverse(
282247
:param int limit: (Optional) limit number of filtered items to this amount (-1 means unlimited).
283248
This is a rough limit, actual results could be a bit longer
284249
:return: number of ops
250+
251+
Non-raw output example of yielded item:
252+
253+
.. code-block:: python
254+
255+
{
256+
'from': 'viz',
257+
'to': 'null',
258+
'amount': '1.000 VIZ',
259+
'memo': 'test',
260+
'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
261+
'block': 5,
262+
'trx_in_block': 0,
263+
'op_in_trx': 0,
264+
'virtual_op': 0,
265+
'timestamp': '2020-05-19T08:10:47',
266+
'account': 'viz',
267+
'type': 'transfer',
268+
'_id': 'd1ed77ae861bb1ecc26a82dd275cc80e5ac124a6',
269+
'index': 0,
270+
}
271+
272+
Raw output example of single item:
273+
274+
.. code-block:: python
275+
276+
[
277+
0,
278+
{
279+
'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
280+
'block': 5,
281+
'trx_in_block': 0,
282+
'op_in_trx': 0,
283+
'virtual_op': 0,
284+
'timestamp': '2020-05-19T08:10:47',
285+
'op': ['transfer', {'from': 'viz', 'to': 'null', 'amount': '1.000 VIZ', 'memo': 'test'}],
286+
},
287+
]
285288
"""
286289
op_count = 0
287290

0 commit comments

Comments
 (0)