Test excluding the node if there's the NODE-level error in the failure_code
(node_factory, bitcoind)
| 151 | |
| 152 | |
| 153 | def test_pay_exclude_node(node_factory, bitcoind): |
| 154 | """Test excluding the node if there's the NODE-level error in the failure_code |
| 155 | """ |
| 156 | # FIXME: Remove our reliance on HTLCs failing on startup and the need for |
| 157 | # this plugin |
| 158 | opts = [ |
| 159 | {'disable-mpp': None}, |
| 160 | {'plugin': os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')}, |
| 161 | {}, |
| 162 | {'fee-base': 100, 'fee-per-satoshi': 1000}, |
| 163 | {} |
| 164 | ] |
| 165 | l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=opts) |
| 166 | node_factory.join_nodes([l1, l2, l3], wait_for_announce=True) |
| 167 | amount = 10**8 |
| 168 | |
| 169 | inv = l3.rpc.invoice(amount, "test1", 'description')['bolt11'] |
| 170 | # It should have eliminated route hint. |
| 171 | with pytest.raises(RpcError, match=r"Failed after 1 attempts. We got a weird error \(temporary_node_failure\) for the invoice's route hint \([0-9x]*/0\): disabling it for this payment. Then routing failed: We could not find a usable set of paths. All 1 channels to the destination are disabled."): |
| 172 | l1.rpc.pay(inv) |
| 173 | |
| 174 | # Get a fresh invoice, but do it before other routes exist, so routehint |
| 175 | # will be via l2. |
| 176 | inv = l3.rpc.invoice(amount, "test2", 'description')['bolt11'] |
| 177 | assert only_one(l1.rpc.decode(inv)['routes'])[0]['pubkey'] == l2.info['id'] |
| 178 | |
| 179 | # l1->l4->l5->l3 is the longer route. This makes sure this route won't be |
| 180 | # tried for the first pay attempt. Just to be sure we also raise the fees |
| 181 | # that l4 leverages. |
| 182 | l1.rpc.connect(l4.info['id'], 'localhost', l4.port) |
| 183 | l4.rpc.connect(l5.info['id'], 'localhost', l5.port) |
| 184 | l5.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 185 | scid14, _ = l1.fundchannel(l4, 10**6, wait_for_active=False) |
| 186 | scid45, _ = l4.fundchannel(l5, 10**6, wait_for_active=False) |
| 187 | scid53, _ = l5.fundchannel(l3, 10**6, wait_for_active=False) |
| 188 | mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5]) |
| 189 | |
| 190 | l1.daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE' |
| 191 | .format(scid14), |
| 192 | r'update for channel {}/1 now ACTIVE' |
| 193 | .format(scid14), |
| 194 | r'update for channel {}/0 now ACTIVE' |
| 195 | .format(scid45), |
| 196 | r'update for channel {}/1 now ACTIVE' |
| 197 | .format(scid45), |
| 198 | r'update for channel {}/0 now ACTIVE' |
| 199 | .format(scid53), |
| 200 | r'update for channel {}/1 now ACTIVE' |
| 201 | .format(scid53)]) |
| 202 | |
| 203 | # This `pay` will work |
| 204 | l1.rpc.pay(inv) |
| 205 | |
| 206 | [p['status'] for p in l1.rpc.listsendpays()['payments']] == ['failed', 'failed', 'complete'] |
| 207 | |
| 208 | |
| 209 | def test_pay0(node_factory): |
nothing calls this directly
no test coverage detected