diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ffd42f4d..ba2b841d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,12 +14,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: ["3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: install dependencies @@ -33,4 +33,6 @@ jobs: mkdir test-results pytest -v -s --junitxml=test-reports/junit.xml --cov=crypto --cov-config=.coveragerc --cov-report xml - name: Codecov - run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v7 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 5176d6e9..1fe45f11 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ dist/ .vscode .vs venv -venv/ \ No newline at end of file +venv/ +.venv diff --git a/crypto/utils/slot.py b/crypto/utils/slot.py index 23b3d080..ba934d97 100644 --- a/crypto/utils/slot.py +++ b/crypto/utils/slot.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone from crypto.configuration.network import get_network @@ -9,7 +9,8 @@ def get_time(): Returns: int: difference in seconds """ - now = datetime.utcnow() + # Network epochs are naive UTC datetimes, so drop tzinfo to keep them comparable + now = datetime.now(timezone.utc).replace(tzinfo=None) network = get_network() seconds = int((now - network['epoch']).total_seconds()) return seconds diff --git a/setup.cfg b/setup.cfg index 3a6687a9..3ee7b291 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[aliases] -test=pytest - [flake8] max-line-length = 100 application-import-names = crypto diff --git a/setup.py b/setup.py index 0a5c77db..2eb98f16 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,19 @@ -import sys - import setuptools requires = [ - 'base58', - 'binary-helpers', - 'coincurve' + 'base58>=2.1.1', + 'binary-helpers>=0.0.4', + 'coincurve>=21.0.0', ] tests_require = [ - 'flake8>=3.5.0', - 'flake8-import-order>=0.17.1', - 'flake8-print>=3.1.0', - 'flake8-quotes>=1.0.0', - 'pytest>=3.6.1', - 'pytest-cov>=2.5.1' + 'flake8>=7.5.0', + 'flake8-import-order>=0.19.2', + 'flake8-print>=5.0.0', + 'flake8-quotes>=3.4.0', + 'pytest>=9.2.0', + 'pytest-cov>=7.1.0', ] extras_require = { @@ -23,8 +21,6 @@ 'dev': requires + tests_require } -setup_requires = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] - setuptools.setup( name='arkecosystem-crypto', description='A simple Cryptography Implementation in Python for the Ark Blockchain.', @@ -33,8 +29,7 @@ author_email='info@ark.io', url='https://github.com/ArkEcosystem/python-crypto', packages=setuptools.find_packages(exclude=['tests', 'tests.*']), + python_requires='>=3.11', install_requires=requires, extras_require=extras_require, - tests_require=tests_require, - setup_requires=setup_requires, ) diff --git a/tests/utils/test_slot.py b/tests/utils/test_slot.py index fa17037a..58821b59 100644 --- a/tests/utils/test_slot.py +++ b/tests/utils/test_slot.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone from crypto.utils.slot import get_epoch, get_time @@ -11,3 +11,15 @@ def test_get_epoch(): def test_get_time(): result = get_time() assert isinstance(result, int) + + +def test_get_time_returns_seconds_since_epoch_in_utc(): + def seconds_since_epoch(): + now = datetime.now(timezone.utc).replace(tzinfo=None) + return int((now - get_epoch()).total_seconds()) + + before = seconds_since_epoch() + result = get_time() + after = seconds_since_epoch() + + assert before <= result <= after