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

Function test_zeroconf_mindepth

tests/test_opening.py:2192–2235  ·  view source on GitHub ↗

Check that funder/fundee can customize mindepth. Zeroconf will use this to set the mindepth to 0, which coupled with an artificial depth=0 event that will result in an immediate `channel_ready` being sent.

(bitcoind, node_factory)

Source from the content-addressed store, hash-verified

2190
2191
2192def test_zeroconf_mindepth(bitcoind, node_factory):
2193 """Check that funder/fundee can customize mindepth.
2194
2195 Zeroconf will use this to set the mindepth to 0, which coupled
2196 with an artificial depth=0 event that will result in an immediate
2197 `channel_ready` being sent.
2198
2199 """
2200 plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
2201
2202 l1, l2 = node_factory.get_nodes(2, opts=[
2203 {},
2204 {
2205 'plugin': str(plugin_path),
2206 'zeroconf_allow': '038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b',
2207 'zeroconf_mindepth': '2',
2208 },
2209 ])
2210
2211 # Try to open a mindepth=6 channel
2212 l1.fundwallet(10**6)
2213
2214 l1.connect(l2)
2215 assert (int(l1.rpc.listpeers()['peers'][0]['features'], 16) >> 50) & 0x02 != 0
2216
2217 # Now start the negotiation, l1 should have negotiated zeroconf,
2218 # and use their own mindepth=6, while l2 uses mindepth=2 from the
2219 # plugin
2220 l1.rpc.fundchannel(l2.info['id'], 'all', mindepth=6)
2221
2222 assert l1.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 6}]
2223 assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 2}]
2224
2225 bitcoind.generate_block(2, wait_for_mempool=1) # Confirm on the l2 side.
2226 l2.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY')
2227 # l1 should not be sending channel_ready yet, it is
2228 # configured to wait for 6 confirmations.
2229 assert not l1.daemon.is_in_log(r'peer_out WIRE_CHANNEL_READY')
2230
2231 bitcoind.generate_block(4) # Confirm on the l2 side.
2232 l1.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY')
2233
2234 wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == "CHANNELD_NORMAL")
2235 wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['state'] == "CHANNELD_NORMAL")
2236
2237
2238def test_zeroconf_open(bitcoind, node_factory):

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
only_oneFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
listpeerchannelsMethod · 0.80
connectMethod · 0.45
listpeersMethod · 0.45
fundchannelMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected