mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pytest: fix test_multifunding_feerates
There's a 1 in 256 chance that our signature on the transaction is 70, not 71 bytes long. This changes the freerate. So fix up the weight in this case, to be the expected weight. ``` @unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Fees on elements are different") @pytest.mark.developer("uses dev-fail") @pytest.mark.openchannel('v1') # v2 the weight calculation is off by 3 deftest_multifunding_feerates(node_factory, bitcoind): ''' Test feerate parameters for multifundchannel ''' funding_tx_feerate = '10000perkw' commitment_tx_feerate_int = 2000 commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw' l1, l2, l3 = node_factory.get_nodes(3, opts={'log-level': 'debug'}) l1.fundwallet(1 << 26) def_connect_str(node): return'{}@localhost:{}'.format(node.info['id'], node.port) destinations = [{"id": _connect_str(l2), 'amount': 50000}] res = l1.rpc.multifundchannel(destinations, feerate=funding_tx_feerate, commitment_feerate=commitment_tx_feerate) entry = bitcoind.rpc.getmempoolentry(res['txid']) weight = entry['weight'] expected_fee = int(funding_tx_feerate[:-5]) * weight // 1000 > assert expected_fee == entry['fees']['base'] * 10 ** 8 E AssertionError: assert 7000 == (Decimal('0.00007010') * (10 ** 8)) tests/test_connection.py:1982: AssertionError ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
25699994e5
commit
9152b8c424
@ -1978,6 +1978,9 @@ def test_multifunding_feerates(node_factory, bitcoind):
|
|||||||
entry = bitcoind.rpc.getmempoolentry(res['txid'])
|
entry = bitcoind.rpc.getmempoolentry(res['txid'])
|
||||||
weight = entry['weight']
|
weight = entry['weight']
|
||||||
|
|
||||||
|
# If signature is unexpectedly short, we get a spurious failure here!
|
||||||
|
res = bitcoind.rpc.decoderawtransaction(res['tx'])
|
||||||
|
weight += 71 - len(res['vin'][0]['txinwitness'][0]) // 2
|
||||||
expected_fee = int(funding_tx_feerate[:-5]) * weight // 1000
|
expected_fee = int(funding_tx_feerate[:-5]) * weight // 1000
|
||||||
assert expected_fee == entry['fees']['base'] * 10 ** 8
|
assert expected_fee == entry['fees']['base'] * 10 ** 8
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user