Skip to content

Commit

Permalink
Version 1.3.2.2: better handle None rate
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNaif2018 committed Jun 29, 2021
1 parent b8212aa commit 4420bf3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Latest changes

## 1.3.2.2

Handle None values better in `convert_amount_type` to always return Decimal.

## 1.3.2.1

PyPI readme fixes
Expand Down Expand Up @@ -384,7 +388,7 @@ This bugfix fixes xpub sending, and exception raising.

Structural improvements and more

**Structural improvements**
### Structural improvements

This version makes async version the default one used in the repo.

Expand All @@ -397,7 +401,7 @@ It means less time spent, and instead of porting new features to sync/async vers

The async branch will be deleted.

**Sending transactions improvements**
### Sending transactions improvements

Also, the long awaited `pay_to_many` function to do batch transactions is there!
Both `pay_to` and `pay_to_many` now have optional `feerate`, which is sat/vbyte rate.
Expand Down Expand Up @@ -502,7 +506,7 @@ btc.poll_updates()

The following code would print

```
```text
new_transaction
some_tx_hash
dict of tx hash data
Expand Down Expand Up @@ -560,7 +564,7 @@ This adds in new LN class and related methods.

Also, now it is not needed to fill in all values, some defaults are used:

```
```text
rpc_user="electrum"
rpc_pass="electrumz"
rpc_url="http://localhost:5000" for bitcoin daemon and "http://localhost:5001" for lightning daemon.
Expand Down
2 changes: 2 additions & 0 deletions bitcart/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def convert_amount_type(amount: str) -> Decimal:
Returns:
Decimal
"""
if amount == "None":
return Decimal("Nan")
return Decimal(amount)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def main() -> None:
setup(
name="bitcart",
packages=find_packages(),
version="1.3.2.1",
version="1.3.2.2",
license="LGPLv3+",
description="BitcartCC coins support library",
long_description=open("README.md").read(),
Expand Down
7 changes: 5 additions & 2 deletions tests/coins/btc/test_without_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ async def test_help(btc):
assert "help" in data


@pytest.mark.parametrize("currency", ["USD", "RUB", "JPY"])
@pytest.mark.parametrize("currency", ["USD", "RUB", "JPY", "nonexisting"])
async def test_rate(btc, currency):
price = await btc.rate(currency)
assert price > 0
if currency == "nonexisting":
assert price.is_nan()
else:
assert price > 0
assert isinstance(price, decimal.Decimal)


Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_convertability():

def test_convert_amount_type():
assert convert_amount_type("1") == Decimal("1")
assert convert_amount_type("None").is_nan()


@pytest.mark.asyncio
Expand Down

0 comments on commit 4420bf3

Please sign in to comment.