MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_funding_v2_cancel_race

Function test_funding_v2_cancel_race

tests/test_connection.py:1507–1576  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

1505@unittest.skipIf(SLOW_MACHINE and not VALGRIND, "Way too taxing on CI machines")
1506@pytest.mark.openchannel('v2')
1507def 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

Callers

nothing calls this directly

Calls 11

wait_forFunction · 0.90
generate_blockMethod · 0.80
get_nodesMethod · 0.80
fundpsbtMethod · 0.80
openchannel_initMethod · 0.80
unreserveinputsMethod · 0.80
get_nodeMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
connectMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected