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

Function test_close_weight_estimate

tests/test_closing.py:4069–4095  ·  view source on GitHub ↗

closingd uses the expected closing tx weight to constrain fees; make sure that lightningd agrees once it has the actual agreed tx

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

4067
4068
4069def test_close_weight_estimate(node_factory, bitcoind):
4070 """closingd uses the expected closing tx weight to constrain fees; make sure that lightningd agrees
4071 once it has the actual agreed tx"""
4072 l1, l2 = node_factory.line_graph(2)
4073 l1.rpc.close(l2.info['id'])
4074
4075 # Closingd gives this estimate before it begins
4076 log = l1.daemon.wait_for_log('Expected closing weight = ')
4077 expected_weight = int(re.match('.*Expected closing weight = ([0-9]*),.*', log).group(1))
4078
4079 # This is the actual weight: in theory this could use their
4080 # actual sig, and thus vary, but we don't do that.
4081 log = l1.daemon.wait_for_log('Their actual closing tx fee is')
4082 final_estimate = int(re.match('.*: weight is ([0-9]*).*', log).group(1))
4083
4084 assert final_estimate == expected_weight
4085
4086 log = l1.daemon.wait_for_log('sendrawtransaction: ')
4087 tx = re.match('.*sendrawtransaction: ([0-9a-f]*).*', log).group(1)
4088
4089 # To match the signer's estimate we use the pessimistic estimate
4090 # of 73bytes / signature. We will always end up with at most 71
4091 # bytes since we grind the signatures, and sometimes we get lucky
4092 # and get a 70 byte signature, hence the below ranges.
4093 signed_weight = int(bitcoind.rpc.decoderawtransaction(tx)['weight'])
4094 assert signed_weight + 4 <= final_estimate # 71byte signature
4095 assert signed_weight + 6 >= final_estimate # 70byte signature
4096
4097
4098def test_onchain_close_upstream(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
wait_for_logMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected