Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dist/
.vscode
.vs
venv
venv/
venv/
.venv
5 changes: 3 additions & 2 deletions crypto/utils/slot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from crypto.configuration.network import get_network

Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[aliases]
test=pytest

[flake8]
max-line-length = 100
application-import-names = crypto
Expand Down
25 changes: 10 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
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 = {
'test': tests_require,
'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.',
Expand All @@ -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,
)
14 changes: 13 additions & 1 deletion tests/utils/test_slot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from crypto.utils.slot import get_epoch, get_time

Expand All @@ -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