(node_factory, bitcoind, executor)
| 1505 | @unittest.skipIf(SLOW_MACHINE and not VALGRIND, "Way too taxing on CI machines") |
| 1506 | @pytest.mark.openchannel('v2') |
| 1507 | def test_funding_v2_cancel_race(node_factory, bitcoind, executor): |
| 1508 | l1 = node_factory.get_node() |
| 1509 | |
| 1510 | # make sure we can generate PSBTs. |
| 1511 | addr = l1.rpc.newaddr()['bech32'] |
| 1512 | bitcoind.rpc.sendtoaddress(addr, 2000000 / 10**8) |
| 1513 | bitcoind.generate_block(1) |
| 1514 | wait_for(lambda: len(l1.rpc.listfunds()["outputs"]) != 0) |
| 1515 | |
| 1516 | if node_factory.valgrind: |
| 1517 | num = 5 |
| 1518 | else: |
| 1519 | num = 100 |
| 1520 | |
| 1521 | nodes = node_factory.get_nodes(num) |
| 1522 | |
| 1523 | num_complete = 0 |
| 1524 | num_cancel = 0 |
| 1525 | amount = 100000 |
| 1526 | |
| 1527 | for count, n in enumerate(nodes): |
| 1528 | l1.rpc.connect(n.info['id'], 'localhost', n.port) |
| 1529 | psbt = l1.rpc.fundpsbt(amount, '7500perkw', 250, reserve=0, |
| 1530 | excess_as_change=True, |
| 1531 | min_witness_weight=110)['psbt'] |
| 1532 | start = l1.rpc.openchannel_init(n.info['id'], amount, psbt) |
| 1533 | |
| 1534 | # Submit two of each at once. |
| 1535 | completes = [] |
| 1536 | cancels = [] |
| 1537 | |
| 1538 | # Switch order around. |
| 1539 | for i in range(4): |
| 1540 | if (i + count) % 2 == 0: |
| 1541 | completes.append(executor.submit(l1.rpc.openchannel_update, |
| 1542 | start['channel_id'], |
| 1543 | start['psbt'])) |
| 1544 | else: |
| 1545 | cancels.append(executor.submit(l1.rpc.openchannel_abort, |
| 1546 | start['channel_id'])) |
| 1547 | |
| 1548 | # Only up to one should succeed. |
| 1549 | success = False |
| 1550 | for c in completes: |
| 1551 | try: |
| 1552 | c.result(TIMEOUT) |
| 1553 | num_complete += 1 |
| 1554 | assert not success |
| 1555 | success = True |
| 1556 | except RpcError: |
| 1557 | pass |
| 1558 | |
| 1559 | for c in cancels: |
| 1560 | try: |
| 1561 | c.result(TIMEOUT) |
| 1562 | num_cancel += 1 |
| 1563 | except RpcError: |
| 1564 | pass |
nothing calls this directly
no test coverage detected