mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-01 01:35:14 +00:00
ensures content purchase fails appropriately when exchange rate is not available
This commit is contained in:
parent
be8751cb73
commit
75ecea265d
1 changed files with 8 additions and 1 deletions
|
@ -12,7 +12,7 @@ class PurchaseCommandTests(CommandTestCase):
|
||||||
self.merchant_address = await self.blockchain.get_raw_change_address()
|
self.merchant_address = await self.blockchain.get_raw_change_address()
|
||||||
|
|
||||||
async def priced_stream(
|
async def priced_stream(
|
||||||
self, name='stream', price: Optional[str] = '2.0', currency='LBC', mine=False
|
self, name='stream', price: Optional[str] = '0.2', currency='LBC', mine=False
|
||||||
) -> Transaction:
|
) -> Transaction:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if price and currency:
|
if price and currency:
|
||||||
|
@ -121,6 +121,13 @@ class PurchaseCommandTests(CommandTestCase):
|
||||||
abc_stream = await self.priced_stream('abc')
|
abc_stream = await self.priced_stream('abc')
|
||||||
await self.assertStreamPurchased(abc_stream, lambda: self.daemon.jsonrpc_purchase_create(url='lbry://abc'))
|
await self.assertStreamPurchased(abc_stream, lambda: self.daemon.jsonrpc_purchase_create(url='lbry://abc'))
|
||||||
|
|
||||||
|
# purchase without valid exchange rate fails
|
||||||
|
erm = self.daemon.component_manager.get_component('exchange_rate_manager')
|
||||||
|
for feed in erm.market_feeds:
|
||||||
|
feed.last_check -= 10_000
|
||||||
|
with self.assertRaisesRegex(Exception, "Unable to convert 50 from USD to LBC"):
|
||||||
|
await self.daemon.jsonrpc_purchase_create(claim_id, allow_duplicate_purchase=True)
|
||||||
|
|
||||||
async def test_purchase_and_transaction_list(self):
|
async def test_purchase_and_transaction_list(self):
|
||||||
self.assertItemCount(await self.daemon.jsonrpc_purchase_list(), 0)
|
self.assertItemCount(await self.daemon.jsonrpc_purchase_list(), 0)
|
||||||
self.assertItemCount(await self.daemon.jsonrpc_transaction_list(), 1)
|
self.assertItemCount(await self.daemon.jsonrpc_transaction_list(), 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue