MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_multifunding_feerates

Function test_multifunding_feerates

tests/test_connection.py:2092–2160  ·  view source on GitHub ↗

Test feerate parameters for multifundchannel

(node_factory, bitcoind, anchors)

Source from the content-addressed store, hash-verified

2090@pytest.mark.openchannel('v1') # v2 the weight calculation is off by 3
2091@pytest.mark.parametrize("anchors", [False, True])
2092def test_multifunding_feerates(node_factory, bitcoind, anchors):
2093 '''
2094 Test feerate parameters for multifundchannel
2095 '''
2096 funding_tx_feerate = '10000perkw'
2097 commitment_tx_feerate_int = 2000
2098 commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw'
2099
2100 opts = {'log-level': 'debug'}
2101 if anchors is False:
2102 opts['dev-force-features'] = "-23"
2103 l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
2104
2105 l1.fundwallet(1 << 26)
2106
2107 def _connect_str(node):
2108 return '{}@localhost:{}'.format(node.info['id'], node.port)
2109
2110 destinations = [{"id": _connect_str(l2), 'amount': 50000}]
2111
2112 res = l1.rpc.multifundchannel(destinations, feerate=funding_tx_feerate,
2113 commitment_feerate=commitment_tx_feerate)
2114
2115 entry = bitcoind.rpc.getmempoolentry(res['txid'])
2116 weight = entry['weight']
2117
2118 # If signature is unexpectedly short, we get a spurious failure here!
2119 res = bitcoind.rpc.decoderawtransaction(res['tx'])
2120 weight += 71 - len(res['vin'][0]['txinwitness'][0]) // 2
2121 expected_fee = int(funding_tx_feerate[:-5]) * weight // 1000
2122 assert expected_fee == entry['fees']['base'] * 10 ** 8
2123
2124 # anchors ignores commitment_feerate!
2125 if anchors:
2126 commitment_tx_feerate_int = 3750
2127 commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw'
2128
2129 assert only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['feerate']['perkw'] == commitment_tx_feerate_int
2130 assert only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['feerate']['perkb'] == commitment_tx_feerate_int * 4
2131
2132 txfee = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['last_tx_fee_msat']
2133
2134 # We get the expected close txid, force close the channel, then fish
2135 # the details about the transaction out of the mempoool entry
2136 close_txid = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['scratch_txid']
2137 l1.rpc.dev_fail(l2.info['id'])
2138 l1.wait_for_channel_onchain(l2.info['id'])
2139 entry = bitcoind.rpc.getmempoolentry(close_txid)
2140
2141 # Because of how the anchor outputs protocol is designed,
2142 # we *always* pay for 2 anchor outs and their weight
2143 if anchors:
2144 weight = 1124
2145 else:
2146 # the commitment transactions' feerate is calculated off
2147 # of this fixed weight
2148 weight = 724
2149

Callers

nothing calls this directly

Calls 9

only_oneFunction · 0.90
MillisatoshiClass · 0.90
_connect_strFunction · 0.85
get_nodesMethod · 0.80
fundwalletMethod · 0.80
multifundchannelMethod · 0.80
listpeerchannelsMethod · 0.80
dev_failMethod · 0.80

Tested by

no test coverage detected