1
0

tests: commands: onchain_history: add test for "show_fiat" param

This commit is contained in:
SomberNight
2025-08-13 16:12:21 +00:00
parent d7c76b991b
commit 34f0450798
2 changed files with 3022 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@ import unittest
from unittest import mock from unittest import mock
from decimal import Decimal from decimal import Decimal
from os import urandom from os import urandom
import shutil
import electrum import electrum
from electrum.commands import Commands, eval_bool from electrum.commands import Commands, eval_bool
@@ -177,6 +178,9 @@ class TestCommandsTestnet(ElectrumTestCase):
super().setUp() super().setUp()
self.config = SimpleConfig({'electrum_path': self.electrum_path}) self.config = SimpleConfig({'electrum_path': self.electrum_path})
self.config.NETWORK_OFFLINE = True self.config.NETWORK_OFFLINE = True
shutil.copytree(os.path.join(os.path.dirname(__file__), "fiat_fx_data"), os.path.join(self.electrum_path, "cache"))
self.config.FX_EXCHANGE = "BitFinex"
self.config.FX_CURRENCY = "EUR"
self._default_default_timezone = electrum.util.DEFAULT_TIMEZONE self._default_default_timezone = electrum.util.DEFAULT_TIMEZONE
electrum.util.DEFAULT_TIMEZONE = datetime.timezone.utc electrum.util.DEFAULT_TIMEZONE = datetime.timezone.utc
@@ -620,3 +624,19 @@ class TestCommandsTestnet(ElectrumTestCase):
with self.subTest(msg="timestamp and block height based filtering cannot be used together"): with self.subTest(msg="timestamp and block height based filtering cannot be used together"):
with self.assertRaises(UserFacingException): with self.assertRaises(UserFacingException):
hist = await cmds.onchain_history(wallet_path=wallet_path, year=2019, from_height=1638866, to_height=1665815) hist = await cmds.onchain_history(wallet_path=wallet_path, year=2019, from_height=1638866, to_height=1665815)
with self.subTest(msg="'show_fiat' param"):
self.config.FX_USE_EXCHANGE_RATE = True
hist = await cmds.onchain_history(wallet_path=wallet_path, show_fiat=True)
self.assertEqual(len(hist), 89)
self.assertEqual(
hist[-1],
expected_last_history_item | {
"acquisition_price": "41.67",
"capital_gain": "-1.16",
"fiat_currency": "EUR",
"fiat_default": True,
"fiat_fee": "0.02",
"fiat_rate": "8097.91",
"fiat_value": "-40.51",
}
)