tests: promote method to utility file

We'll reuse it later
This commit is contained in:
niftynei
2021-08-05 12:32:38 -05:00
committed by Rusty Russell
parent 9df4234e8f
commit a9de23f993
3 changed files with 9 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ from pyln.testing.utils import SLOW_MACHINE
from utils import ( from utils import (
only_one, sync_blockheight, wait_for, TIMEOUT, only_one, sync_blockheight, wait_for, TIMEOUT,
account_balance, first_channel_id, closing_fee, TEST_NETWORK, account_balance, first_channel_id, closing_fee, TEST_NETWORK,
scriptpubkey_addr scriptpubkey_addr, calc_lease_fee
) )
import os import os
@@ -718,14 +718,6 @@ def test_penalty_outhtlc(node_factory, bitcoind, executor, chainparams):
assert account_balance(l2, channel_id) == 0 assert account_balance(l2, channel_id) == 0
# check that the fee paid is correct
def calc_lease_fee(amt, feerate, rates):
fee = rates['lease_fee_base_msat']
fee += amt * rates['lease_fee_basis'] // 10
fee += rates['funding_weight'] * feerate
return fee
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@pytest.mark.openchannel('v2') @pytest.mark.openchannel('v2')
@pytest.mark.slow_test @pytest.mark.slow_test

View File

@@ -2,7 +2,7 @@ from fixtures import * # noqa: F401,F403
from fixtures import TEST_NETWORK from fixtures import TEST_NETWORK
from pyln.client import RpcError, Millisatoshi from pyln.client import RpcError, Millisatoshi
from utils import ( from utils import (
only_one, wait_for, sync_blockheight, first_channel_id only_one, wait_for, sync_blockheight, first_channel_id, calc_lease_fee
) )
import pytest import pytest

View File

@@ -74,6 +74,13 @@ def move_matches(exp, mv):
return True return True
def calc_lease_fee(amt, feerate, rates):
fee = rates['lease_fee_base_msat']
fee += amt * rates['lease_fee_basis'] // 10
fee += rates['funding_weight'] * feerate
return fee
def check_coin_moves(n, account_id, expected_moves, chainparams): def check_coin_moves(n, account_id, expected_moves, chainparams):
moves = n.rpc.call('listcoinmoves_plugin')['coin_moves'] moves = n.rpc.call('listcoinmoves_plugin')['coin_moves']
node_id = n.info['id'] node_id = n.info['id']