Skip to content

Commit a9de23f

Browse files
niftyneirustyrussell
authored andcommitted
tests: promote method to utility file
We'll reuse it later
1 parent 9df4234 commit a9de23f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

tests/test_closing.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from utils import (
77
only_one, sync_blockheight, wait_for, TIMEOUT,
88
account_balance, first_channel_id, closing_fee, TEST_NETWORK,
9-
scriptpubkey_addr
9+
scriptpubkey_addr, calc_lease_fee
1010
)
1111

1212
import os
@@ -718,14 +718,6 @@ def test_penalty_outhtlc(node_factory, bitcoind, executor, chainparams):
718718
assert account_balance(l2, channel_id) == 0
719719

720720

721-
# check that the fee paid is correct
722-
def calc_lease_fee(amt, feerate, rates):
723-
fee = rates['lease_fee_base_msat']
724-
fee += amt * rates['lease_fee_basis'] // 10
725-
fee += rates['funding_weight'] * feerate
726-
return fee
727-
728-
729721
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
730722
@pytest.mark.openchannel('v2')
731723
@pytest.mark.slow_test

tests/test_opening.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from fixtures import TEST_NETWORK
33
from pyln.client import RpcError, Millisatoshi
44
from utils import (
5-
only_one, wait_for, sync_blockheight, first_channel_id
5+
only_one, wait_for, sync_blockheight, first_channel_id, calc_lease_fee
66
)
77

88
import pytest

tests/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ def move_matches(exp, mv):
7474
return True
7575

7676

77+
def calc_lease_fee(amt, feerate, rates):
78+
fee = rates['lease_fee_base_msat']
79+
fee += amt * rates['lease_fee_basis'] // 10
80+
fee += rates['funding_weight'] * feerate
81+
return fee
82+
83+
7784
def check_coin_moves(n, account_id, expected_moves, chainparams):
7885
moves = n.rpc.call('listcoinmoves_plugin')['coin_moves']
7986
node_id = n.info['id']

0 commit comments

Comments
 (0)