From f41cfbfb97fafbf72988b145a1c5db2a040286a1 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 21 Feb 2020 14:15:17 -0300 Subject: [PATCH] max wallet server payment fee defaults to 0 and component doesnt start in that case --- lbry/conf.py | 2 +- lbry/wallet/usage_payment.py | 2 ++ .../integration/blockchain/test_wallet_server_sessions.py | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lbry/conf.py b/lbry/conf.py index c204a49f5..fa9b6fed4 100644 --- a/lbry/conf.py +++ b/lbry/conf.py @@ -558,7 +558,7 @@ class Config(CLIConfig): "Don't download streams with fees exceeding this amount. When set to " "null, the amount is unbounded.", {'currency': 'USD', 'amount': 50.0} ) - max_wallet_server_fee = String("Maximum daily LBC amount allowed as payment for wallet servers.", "1.0") + max_wallet_server_fee = String("Maximum daily LBC amount allowed as payment for wallet servers.", "0.0") # reflector settings reflect_streams = Toggle( diff --git a/lbry/wallet/usage_payment.py b/lbry/wallet/usage_payment.py index 8195535db..9e7c6857b 100644 --- a/lbry/wallet/usage_payment.py +++ b/lbry/wallet/usage_payment.py @@ -64,6 +64,8 @@ class WalletServerPayer: self._on_payment_controller.add(tx) async def start(self, ledger=None, wallet=None): + if lbc_to_dewies(self.max_fee) < 1: + return self.ledger = ledger self.wallet = wallet self.running = True diff --git a/tests/integration/blockchain/test_wallet_server_sessions.py b/tests/integration/blockchain/test_wallet_server_sessions.py index df52b446f..96564dcd5 100644 --- a/tests/integration/blockchain/test_wallet_server_sessions.py +++ b/tests/integration/blockchain/test_wallet_server_sessions.py @@ -57,6 +57,13 @@ class TestUsagePayment(CommandTestCase): async def test_single_server_payment(self): wallet_pay_service = self.daemon.component_manager.get_component('wallet_server_payments') wallet_pay_service.payment_period = 1 + # only starts with a positive max key fee + wallet_pay_service.max_fee = "0.0" + await wallet_pay_service.start(ledger=self.ledger, wallet=self.wallet) + self.assertFalse(wallet_pay_service.running) + wallet_pay_service.max_fee = "1.0" + await wallet_pay_service.start(ledger=self.ledger, wallet=self.wallet) + self.assertTrue(wallet_pay_service.running) await wallet_pay_service.stop() await wallet_pay_service.start(ledger=self.ledger, wallet=self.wallet)