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

Function test_wumbo_channels

tests/test_connection.py:3551–3625  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

3549@pytest.mark.openchannel('v1')
3550@pytest.mark.openchannel('v2')
3551def test_wumbo_channels(node_factory, bitcoind):
3552 # l3 is not wumbo.
3553 l1, l2, l3 = node_factory.get_nodes(3, opts=[{}, {}, {'dev-force-features': '-19'}])
3554 conn = l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3555
3556 expected_features = expected_peer_features()
3557 assert conn['features'] == expected_features
3558 assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['features'] == expected_features
3559
3560 # Now, can we open a giant channel?
3561 l1.fundwallet(1 << 26)
3562 l1.rpc.fundchannel(l2.info['id'], 1 << 24)
3563
3564 # Get that mined, and announced.
3565 bitcoind.generate_block(6, wait_for_mempool=1)
3566
3567 # Make sure l3 is ready to receive channel announcement!
3568 sync_blockheight(bitcoind, [l1, l2, l3])
3569 # Connect l3, get gossip.
3570 l3.rpc.connect(l1.info['id'], 'localhost', port=l1.port)
3571
3572 # Make sure channel capacity is what we expected (might need to wait for
3573 # both channel updates!
3574 wait_for(lambda: [c['amount_msat'] for c in l3.rpc.listchannels()['channels']]
3575 == [Millisatoshi(str(1 << 24) + "sat")] * 2)
3576
3577 # Make sure channel features are right from channel_announcement
3578 assert ([c['features'] for c in l3.rpc.listchannels()['channels']]
3579 == [expected_channel_features()] * 2)
3580
3581 # Make sure we can't open a wumbo channel if we don't agree.
3582 with pytest.raises(RpcError, match='Amount exceeded'):
3583 l1.rpc.fundchannel(l3.info['id'], 1 << 24)
3584
3585 # But we can open and announce a normal one.
3586 l1.rpc.fundchannel(l3.info['id'], 'all')
3587 bitcoind.generate_block(6, wait_for_mempool=1)
3588 wait_for(lambda: l1.channel_state(l3) == 'CHANNELD_NORMAL')
3589
3590 # Make sure l2 sees correct size.
3591 wait_for(lambda: [c['amount_msat'] for c in l2.rpc.listchannels(l1.get_channel_scid(l3))['channels']]
3592 == [Millisatoshi(str((1 << 24) - 1) + "sat")] * 2)
3593
3594 # Make sure 'all' works with wumbo peers.
3595 l1.rpc.close(l2.info['id'])
3596 bitcoind.generate_block(1, wait_for_mempool=1)
3597 wait_for(lambda: l1.channel_state(l2) == 'ONCHAIN')
3598 wait_for(lambda: l2.channel_state(l1) == 'ONCHAIN')
3599
3600 l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3601 l1.rpc.fundchannel(l2.info['id'], 'all')
3602 bitcoind.generate_block(1, wait_for_mempool=1)
3603 wait_for(lambda: 'CHANNELD_NORMAL' in [c['state'] for c in l1.rpc.listpeerchannels(l2.info['id'])['channels']])
3604 wait_for(lambda: 'CHANNELD_NORMAL' in [c['state'] for c in l2.rpc.listpeerchannels(l1.info['id'])['channels']])
3605
3606 # Exact amount depends on fees, but it will be wumbo!
3607 chan = only_one([c for c in l1.rpc.listpeerchannels(l2.info['id'])['channels'] if c['state'] == 'CHANNELD_NORMAL'])
3608 amount = chan['funding']['local_funds_msat']

Callers

nothing calls this directly

Calls 15

expected_peer_featuresFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
wait_forFunction · 0.90
MillisatoshiClass · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
channel_stateMethod · 0.80
get_channel_scidMethod · 0.80
listpeerchannelsMethod · 0.80

Tested by

no test coverage detected