lbry-sdk/tests/unit/core/test_ExchangeRateManager.py

39 lines
1.1 KiB
Python
Raw Normal View History

2016-10-14 22:15:51 +02:00
from lbrynet.metadata import Fee
2016-09-26 03:35:37 +02:00
from lbrynet.lbrynet_daemon import ExchangeRateManager
2016-07-28 22:27:16 +02:00
from twisted.trial import unittest
2016-09-30 06:06:07 +02:00
from tests import util
2016-07-28 22:27:16 +02:00
2016-09-26 03:35:37 +02:00
class FeeFormatTest(unittest.TestCase):
2016-07-28 22:27:16 +02:00
def test_fee_created_with_correct_inputs(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
2016-10-14 22:15:51 +02:00
fee = Fee.FeeValidator(fee_dict)
2016-07-28 22:27:16 +02:00
self.assertEqual(10.0, fee['USD']['amount'])
2016-09-26 03:35:37 +02:00
class FeeTest(unittest.TestCase):
2016-07-28 22:27:16 +02:00
def setUp(self):
2016-09-30 06:06:07 +02:00
util.resetTime(self)
2016-07-28 22:27:16 +02:00
def test_fee_converts_to_lbc(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
2016-09-30 06:06:07 +02:00
rates = {
'BTCLBC': {'spot': 3.0, 'ts': util.DEFAULT_ISO_TIME + 1},
'USDBTC': {'spot': 2.0, 'ts': util.DEFAULT_ISO_TIME + 2}
}
2016-09-26 03:35:37 +02:00
manager = ExchangeRateManager.DummyExchangeRateManager(rates)
2016-09-30 06:06:07 +02:00
result = manager.to_lbc(fee_dict).amount
self.assertEqual(60.0, result)