Test multiple channels between same nodes
(node_factory, executor, bitcoind)
| 4067 | @pytest.mark.openchannel('v1') |
| 4068 | @pytest.mark.openchannel('v2') |
| 4069 | def test_multichan(node_factory, executor, bitcoind): |
| 4070 | """Test multiple channels between same nodes""" |
| 4071 | l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True}) |
| 4072 | |
| 4073 | scid12 = l1.get_channel_scid(l2) |
| 4074 | scid23a = l2.get_channel_scid(l3) |
| 4075 | |
| 4076 | # Now fund *second* channel l2->l3 (slightly larger) |
| 4077 | bitcoind.rpc.sendtoaddress(l2.rpc.newaddr('bech32')['bech32'], 0.1) |
| 4078 | bitcoind.generate_block(1) |
| 4079 | sync_blockheight(bitcoind, [l1, l2, l3]) |
| 4080 | l2.rpc.fundchannel(l3.info['id'], '0.01001btc') |
| 4081 | assert(len(l2.rpc.listpeerchannels(l3.info['id'])['channels']) == 2) |
| 4082 | assert(len(l3.rpc.listpeerchannels(l2.info['id'])['channels']) == 2) |
| 4083 | |
| 4084 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 4085 | sync_blockheight(bitcoind, [l1, l2, l3]) |
| 4086 | # Make sure new channel is also CHANNELD_NORMAL |
| 4087 | wait_for(lambda: [c['state'] for c in l2.rpc.listpeerchannels(l3.info['id'])['channels']] == ["CHANNELD_NORMAL", "CHANNELD_NORMAL"]) |
| 4088 | |
| 4089 | # Dance around to get the *other* scid. |
| 4090 | wait_for(lambda: all(['short_channel_id' in c for c in l3.rpc.listpeerchannels()['channels']])) |
| 4091 | scids = [c['short_channel_id'] for c in l3.rpc.listpeerchannels()['channels']] |
| 4092 | assert len(scids) == 2 |
| 4093 | |
| 4094 | if scids[0] == scid23a: |
| 4095 | scid23b = scids[1] |
| 4096 | else: |
| 4097 | assert scids[1] == scid23a |
| 4098 | scid23b = scids[0] |
| 4099 | |
| 4100 | # Test paying by each, |
| 4101 | route = [{'amount_msat': 100001001, |
| 4102 | 'id': l2.info['id'], |
| 4103 | 'delay': 11, |
| 4104 | # Unneeded |
| 4105 | 'channel': scid12}, |
| 4106 | {'amount_msat': 100000000, |
| 4107 | 'id': l3.info['id'], |
| 4108 | 'delay': 5, |
| 4109 | 'channel': scid23a}] |
| 4110 | |
| 4111 | before = l2.rpc.listpeerchannels(l3.info['id'])['channels'] |
| 4112 | inv1 = l3.rpc.invoice(100000000, "invoice", "invoice") |
| 4113 | l1.rpc.sendpay(route, inv1['payment_hash'], payment_secret=inv1['payment_secret']) |
| 4114 | l1.rpc.waitsendpay(inv1['payment_hash']) |
| 4115 | |
| 4116 | # Wait until HTLCs fully settled |
| 4117 | wait_for(lambda: [c['htlcs'] for c in l2.rpc.listpeerchannels(l3.info['id'])['channels']] == [[], []]) |
| 4118 | after = l2.rpc.listpeerchannels(l3.info['id'])['channels'] |
| 4119 | |
| 4120 | if before[0]['short_channel_id'] == scid23a: |
| 4121 | chan23a_idx = 0 |
| 4122 | chan23b_idx = 1 |
| 4123 | else: |
| 4124 | chan23a_idx = 1 |
| 4125 | chan23b_idx = 0 |
| 4126 |
nothing calls this directly
no test coverage detected