Test multiple channels between same nodes
(node_factory, executor, bitcoind)
| 3841 | @pytest.mark.openchannel('v1') |
| 3842 | @pytest.mark.openchannel('v2') |
| 3843 | def test_multichan_stress(node_factory, executor, bitcoind): |
| 3844 | """Test multiple channels between same nodes""" |
| 3845 | l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True, |
| 3846 | 'dev-no-reconnect': None}) |
| 3847 | |
| 3848 | scid23 = first_scid(l2, l3) |
| 3849 | # Now fund *second* channel l2->l3 (slightly larger) |
| 3850 | bitcoind.rpc.sendtoaddress(l2.rpc.newaddr('bech32')['bech32'], 0.1) |
| 3851 | bitcoind.generate_block(1) |
| 3852 | sync_blockheight(bitcoind, [l2]) |
| 3853 | l2.rpc.fundchannel(l3.info['id'], '0.01001btc') |
| 3854 | assert(len(l2.rpc.listpeerchannels(l3.info['id'])['channels']) == 2) |
| 3855 | assert(len(l3.rpc.listpeerchannels(l2.info['id'])['channels']) == 2) |
| 3856 | |
| 3857 | # Make sure gossip works. |
| 3858 | mine_funding_to_announce(bitcoind, [l1, l2, l3], num_blocks=6, wait_for_mempool=1) |
| 3859 | wait_for(lambda: len(l1.rpc.listchannels(source=l3.info['id'])['channels']) == 2) |
| 3860 | |
| 3861 | # We use sendpay directly here, because xpay learns and refuses to pay! |
| 3862 | route = [{'amount_msat': 101, |
| 3863 | 'id': l2.info['id'], |
| 3864 | 'delay': 16, |
| 3865 | 'channel': first_scid(l1, l2)}, |
| 3866 | {'amount_msat': 100, |
| 3867 | 'id': l3.info['id'], |
| 3868 | 'delay': 10, |
| 3869 | # We say this, but l2 will choose. |
| 3870 | 'channel': scid23}] |
| 3871 | |
| 3872 | def send_many_payments(): |
| 3873 | passes = 0 |
| 3874 | fails = 0 |
| 3875 | # Make sure we try many times, and get at least one pass and fail. |
| 3876 | while passes == 0 or fails == 0 or passes + fails < 30: |
| 3877 | inv = l3.rpc.invoice(100, "label-" + str(passes + fails), "desc") |
| 3878 | l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret']) |
| 3879 | time.sleep(0.05) |
| 3880 | try: |
| 3881 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 3882 | passes += 1 |
| 3883 | except RpcError: |
| 3884 | fails += 1 |
| 3885 | pass |
| 3886 | |
| 3887 | # Send a heap of payments, while reconnecting... |
| 3888 | fut = executor.submit(send_many_payments) |
| 3889 | |
| 3890 | for _ in range(30): |
| 3891 | l3.rpc.disconnect(l2.info['id'], force=True) |
| 3892 | time.sleep(0.1) |
| 3893 | l3.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3894 | fut.result(TIMEOUT) |
| 3895 | |
| 3896 | wait_for(lambda: only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 3897 | inv = l3.rpc.invoice(50000000, "invoice4", "invoice4") |
| 3898 | l1.rpc.xpay(inv['bolt11']) |
| 3899 | |
| 3900 |
nothing calls this directly
no test coverage detected