Test multiple channels between same nodes
(node_factory, executor, bitcoind)
| 3890 | @pytest.mark.openchannel('v1') |
| 3891 | @pytest.mark.openchannel('v2') |
| 3892 | def test_multichan_stress(node_factory, executor, bitcoind): |
| 3893 | """Test multiple channels between same nodes""" |
| 3894 | l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True, |
| 3895 | 'dev-no-reconnect': None}) |
| 3896 | |
| 3897 | scid23 = first_scid(l2, l3) |
| 3898 | # Now fund *second* channel l2->l3 (slightly larger) |
| 3899 | bitcoind.rpc.sendtoaddress(l2.rpc.newaddr('bech32')['bech32'], 0.1) |
| 3900 | bitcoind.generate_block(1) |
| 3901 | sync_blockheight(bitcoind, [l2]) |
| 3902 | l2.rpc.fundchannel(l3.info['id'], '0.01001btc') |
| 3903 | assert(len(l2.rpc.listpeerchannels(l3.info['id'])['channels']) == 2) |
| 3904 | assert(len(l3.rpc.listpeerchannels(l2.info['id'])['channels']) == 2) |
| 3905 | |
| 3906 | # Make sure gossip works. |
| 3907 | mine_funding_to_announce(bitcoind, [l1, l2, l3], num_blocks=6, wait_for_mempool=1) |
| 3908 | wait_for(lambda: len(l1.rpc.listchannels(source=l3.info['id'])['channels']) == 2) |
| 3909 | |
| 3910 | # We use sendpay directly here, because xpay learns and refuses to pay! |
| 3911 | route = [{'amount_msat': 101, |
| 3912 | 'id': l2.info['id'], |
| 3913 | 'delay': 16, |
| 3914 | 'channel': first_scid(l1, l2)}, |
| 3915 | {'amount_msat': 100, |
| 3916 | 'id': l3.info['id'], |
| 3917 | 'delay': 10, |
| 3918 | # We say this, but l2 will choose. |
| 3919 | 'channel': scid23}] |
| 3920 | |
| 3921 | def send_many_payments(): |
| 3922 | passes = 0 |
| 3923 | fails = 0 |
| 3924 | # Make sure we try many times, and get at least one pass and fail. |
| 3925 | while passes == 0 or fails == 0 or passes + fails < 30: |
| 3926 | inv = l3.rpc.invoice(100, "label-" + str(passes + fails), "desc") |
| 3927 | l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret']) |
| 3928 | time.sleep(0.05) |
| 3929 | try: |
| 3930 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 3931 | passes += 1 |
| 3932 | except RpcError: |
| 3933 | fails += 1 |
| 3934 | pass |
| 3935 | |
| 3936 | # Send a heap of payments, while reconnecting... |
| 3937 | fut = executor.submit(send_many_payments) |
| 3938 | |
| 3939 | for _ in range(30): |
| 3940 | l3.rpc.disconnect(l2.info['id'], force=True) |
| 3941 | time.sleep(0.1) |
| 3942 | l3.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3943 | fut.result(TIMEOUT) |
| 3944 | |
| 3945 | wait_for(lambda: only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 3946 | inv = l3.rpc.invoice(50000000, "invoice4", "invoice4") |
| 3947 | l1.rpc.xpay(inv['bolt11']) |
| 3948 | |
| 3949 |
nothing calls this directly
no test coverage detected