Very similar to the test_onchain_middleman, except there's no middleman, we simply want to check that our offered htlc on their unilateral returns to us (and is accounted for correctly)
(node_factory, bitcoind, chainparams, anchors)
| 2346 | |
| 2347 | @pytest.mark.parametrize("anchors", [False, True]) |
| 2348 | def test_onchain_their_unilateral_out(node_factory, bitcoind, chainparams, anchors): |
| 2349 | """ Very similar to the test_onchain_middleman, except there's no |
| 2350 | middleman, we simply want to check that our offered htlc |
| 2351 | on their unilateral returns to us (and is accounted |
| 2352 | for correctly) """ |
| 2353 | |
| 2354 | if chainparams['elements'] and anchors: |
| 2355 | pytest.skip('elementsd anchors unsupported') |
| 2356 | |
| 2357 | # We track channel balances, to verify that accounting is ok. |
| 2358 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 2359 | opts = {'plugin': coin_mvt_plugin} |
| 2360 | if anchors is False: |
| 2361 | opts['dev-force-features'] = "-23" |
| 2362 | |
| 2363 | disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] |
| 2364 | |
| 2365 | l1, l2 = node_factory.line_graph(2, opts=[opts, |
| 2366 | {**opts, **{'disconnect': disconnects}}]) |
| 2367 | channel_id = first_channel_id(l1, l2) |
| 2368 | |
| 2369 | route = l1.single_route(l2.info['id'], 10**8) |
| 2370 | assert len(route) == 1 |
| 2371 | |
| 2372 | q = queue.Queue() |
| 2373 | |
| 2374 | def try_pay(): |
| 2375 | try: |
| 2376 | # rhash is fake (so is payment_secret) |
| 2377 | rhash = 'B1' * 32 |
| 2378 | l1.rpc.sendpay(route, rhash, payment_secret=rhash) |
| 2379 | q.put(None) |
| 2380 | except Exception as err: |
| 2381 | q.put(err) |
| 2382 | |
| 2383 | t = threading.Thread(target=try_pay) |
| 2384 | t.daemon = True |
| 2385 | t.start() |
| 2386 | |
| 2387 | # l2 will drop to chain. |
| 2388 | l2.daemon.wait_for_log(' to AWAITING_UNILATERAL') |
| 2389 | l2.daemon.wait_for_log('sendrawtx exit 0') |
| 2390 | l2.bitcoin.generate_block(1) |
| 2391 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 2392 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 2393 | l1.daemon.wait_for_log('THEIR_UNILATERAL/OUR_HTLC') |
| 2394 | _, txid, blocks = l1.wait_for_onchaind_tx('OUR_HTLC_TIMEOUT_TO_US', |
| 2395 | 'THEIR_UNILATERAL/OUR_HTLC') |
| 2396 | assert blocks == 9 |
| 2397 | |
| 2398 | # l1 should wait til to_self_delay (10), then fulfill onchain |
| 2399 | l2.bitcoin.generate_block(9) |
| 2400 | l2.daemon.wait_for_log('Ignoring output .*_UNILATERAL/THEIR_HTLC') |
| 2401 | |
| 2402 | err = q.get(timeout=10) |
| 2403 | if err: |
| 2404 | print("Got err from sendpay thread") |
| 2405 | raise err |
nothing calls this directly
no test coverage detected