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

37 lines
1.1 KiB
Python
Raw Normal View History

2016-07-28 22:27:16 +02:00
import mock
from lbrynet.core import LBRYMetadata
from lbrynet.lbrynet_daemon import LBRYExchangeRateManager
from twisted.trial import unittest
class LBRYFeeFormatTest(unittest.TestCase):
def test_fee_created_with_correct_inputs(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
fee = LBRYMetadata.LBRYFeeValidator(fee_dict)
self.assertEqual(10.0, fee['USD']['amount'])
class LBRYFeeTest(unittest.TestCase):
def setUp(self):
2016-08-11 02:36:52 +02:00
patcher = mock.patch('time.time')
self.time = patcher.start()
2016-07-28 22:27:16 +02:00
self.time.return_value = 0
2016-08-11 02:36:52 +02:00
self.addCleanup(patcher.stop)
2016-07-28 22:27:16 +02:00
def test_fee_converts_to_lbc(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
rates = {'BTCLBC': {'spot': 3.0, 'ts': 2}, 'USDBTC': {'spot': 2.0, 'ts': 3}}
manager = LBRYExchangeRateManager.DummyExchangeRateManager(rates)
2016-08-11 02:36:52 +02:00
self.assertEqual(60.0, manager.to_lbc(fee_dict).amount)