-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rebalance: constrain can send amounts
- Loading branch information
1 parent
de63838
commit 4036e99
Showing
7 changed files
with
103 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
from unittest import TestCase | ||
from lndmanage.lib.ln_utilities import channel_unbalancedness_and_commit_fee | ||
from lndmanage.lib.ln_utilities import ( | ||
local_balance_to_unbalancedness, | ||
unbalancedness_to_local_balance, | ||
) | ||
|
||
|
||
class LnUtilityTest(TestCase): | ||
def test_unbalancedness_formula(self): | ||
self.assertAlmostEqual( | ||
channel_unbalancedness_and_commit_fee( | ||
500000, 1000000, 1000, False)[0], 0.0) | ||
local_balance_to_unbalancedness(500000, 1000000, 1000, False)[0], 0.0 | ||
) | ||
self.assertAlmostEqual( | ||
channel_unbalancedness_and_commit_fee( | ||
500000, 1000000, 1000, True)[0], -0.002) | ||
local_balance_to_unbalancedness(500000, 1000000, 1000, True)[0], -0.002 | ||
) | ||
self.assertAlmostEqual( | ||
channel_unbalancedness_and_commit_fee( | ||
600000, 1000000, 0, False)[0], -0.2) | ||
local_balance_to_unbalancedness(600000, 1000000, 0, False)[0], -0.2 | ||
) | ||
|
||
# test inverse: | ||
ub = -0.2 | ||
cap = 1000000 | ||
cf = 100 | ||
self.assertAlmostEqual( | ||
ub, | ||
local_balance_to_unbalancedness( | ||
unbalancedness_to_local_balance(ub, cap, 0, False)[0], cap, 0, False | ||
)[0], | ||
) | ||
self.assertAlmostEqual( | ||
ub, | ||
local_balance_to_unbalancedness( | ||
unbalancedness_to_local_balance(ub, cap, cf, True)[0], cap, cf, True | ||
)[0], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters