Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ src/hiero_sdk_python/hapi
# Pytest
.pytest_cache

# Hypothesis state
.hypothesis/

# Lock files
uv.lock
pdm.lock
pubkey.asc
pubkey.asc
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
- docs(setup): specify unit tests for local setup verification. (#1856)
- doc: Fix testnet link in README.md. (#1879)



### Tests
- Format `tests/unit/endpoint_test.py` using black. (`#1792`)
- Implement TCK JSON-RPC server with request handling and error management
- Implement basic fuzz testing [#1872](https://github.com/hiero-ledger/hiero-sdk-python/issues/1872)

### .github
- Added triage members max assignment is protected from being a mentor in `.github/scripts/bot-assignment-check.sh`. (#1718)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dev = [
"grpcio-tools>=1.76.0,<2",
"pytest>=8.3.4,<9",
"pytest-cov>=7.0.0,<8",
"hypothesis>=6.0"
Comment thread
exploreriii marked this conversation as resolved.
Outdated
]

lint = [
Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pythonpath = src

markers =
integration: mark a test as an integration test.
unit: mark a test as a unit test.
unit: mark a test as a unit test.
fuzz: mark a test as fuzz test.
8 changes: 5 additions & 3 deletions src/hiero_sdk_python/hbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(

if isinstance(amount, float) and not math.isfinite(amount):
raise ValueError("Hbar amount must be finite")
if isinstance(amount, Decimal) and not amount.is_finite():
raise ValueError("Hbar amount must be finite")

if unit == HbarUnit.TINYBAR:
if not isinstance(amount, int):
Expand All @@ -56,7 +58,7 @@ def __init__(
amount = Decimal(str(amount))

tinybar = amount * Decimal(unit.tinybar)
if tinybar % 1 != 0:
if tinybar != tinybar.to_integral_value():
raise ValueError("Fractional tinybar value not allowed")

self._amount_in_tinybar = int(tinybar)
Expand All @@ -67,7 +69,7 @@ def to(self, unit: HbarUnit) -> float:

def to_tinybars(self) -> int:
"""Return the amount of hbars in tinybars."""
return int(self.to(HbarUnit.TINYBAR))
return self._amount_in_tinybar

def to_hbars(self) -> float:
"""
Expand Down Expand Up @@ -220,4 +222,4 @@ def __ge__(self, other: object) -> bool:

Hbar.ZERO = Hbar(0)
Hbar.MAX = Hbar(50_000_000_000)
Hbar.MIN = Hbar(-50_000_000_000)
Hbar.MIN = Hbar(-50_000_000_000)
1 change: 1 addition & 0 deletions tests/fuzz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# with <3 from Anto
Comment thread
AntonioCeppellini marked this conversation as resolved.
Loading
Loading