Skip to content

Commit

Permalink
follow-up prev: fix bug in fee_to_depth, and typo and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Jul 14, 2018
1 parent b8ab365 commit 8bb59fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions electrum/simple_config.py
Expand Up @@ -321,8 +321,6 @@ def fee_to_depth(self, target_fee: Real) -> int:
depth += s
if fee <= target_fee:
break
else:
return 0
return depth

def depth_to_fee(self, slider_pos) -> int:
Expand All @@ -333,7 +331,7 @@ def depth_to_fee(self, slider_pos) -> int:
@impose_hard_limits_on_fee
def depth_target_to_fee(self, target: int) -> int:
"""Returns fee in sat/kbyte.
target: desired mempool depth in sat/vbyte
target: desired mempool depth in vbytes
"""
depth = 0
for fee, s in self.mempool_fees:
Expand Down
5 changes: 3 additions & 2 deletions electrum/tests/test_simple_config.py
Expand Up @@ -111,7 +111,7 @@ def test_user_config_is_not_written_with_read_only_config(self):
self.assertEqual({"something": "a"}, result)

def test_depth_target_to_fee(self):
config = SimpleConfig({})
config = SimpleConfig(self.options)
config.mempool_fees = [[49, 100110], [10, 121301], [6, 153731], [5, 125872], [1, 36488810]]
self.assertEqual( 2 * 1000, config.depth_target_to_fee(1000000))
self.assertEqual( 6 * 1000, config.depth_target_to_fee( 500000))
Expand All @@ -134,7 +134,7 @@ def test_depth_target_to_fee(self):
self.assertEqual( 1 * 1000, config.depth_target_to_fee(10 ** 8))

def test_fee_to_depth(self):
config = SimpleConfig({})
config = SimpleConfig(self.options)
config.mempool_fees = [[49, 100000], [10, 120000], [6, 150000], [5, 125000], [1, 36000000]]
self.assertEqual(100000, config.fee_to_depth(500))
self.assertEqual(100000, config.fee_to_depth(50))
Expand All @@ -145,6 +145,7 @@ def test_fee_to_depth(self):
self.assertEqual(370000, config.fee_to_depth(6.5))
self.assertEqual(370000, config.fee_to_depth(6))
self.assertEqual(495000, config.fee_to_depth(5.5))
self.assertEqual(36495000, config.fee_to_depth(0.5))


class TestUserConfig(SequentialTestCase):
Expand Down

1 comment on commit 8bb59fc

@yankielmc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Please sign in to comment.