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

Function test_wait

tests/test_coinmoves.py:1940–1972  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

1938@pytest.mark.openchannel('v1')
1939@pytest.mark.openchannel('v2')
1940def test_wait(node_factory, bitcoind, executor):
1941 l1, l2 = node_factory.get_nodes(2)
1942
1943 fut = executor.submit(l1.rpc.wait, subsystem='chainmoves', indexname='created', nextvalue=1)
1944 l1.daemon.wait_for_log('waiting on chainmoves created 1')
1945
1946 addr = l1.rpc.newaddr('bech32')['bech32']
1947 bitcoind.rpc.sendtoaddress(addr, 200000000 / 10**8)
1948 bitcoind.generate_block(1, wait_for_mempool=1)
1949
1950 out = fut.result(TIMEOUT)
1951 assert out == {'subsystem': 'chainmoves',
1952 'created': 1,
1953 'chainmoves': {'account': 'wallet',
1954 'credit_msat': 200000000000,
1955 'debit_msat': 0}}
1956
1957 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1958 fund = l1.rpc.fundchannel(l2.info['id'], 10000000)
1959 bitcoind.generate_block(1, wait_for_mempool=fund['txid'])
1960 wait_for(lambda: all([c['state'] == 'CHANNELD_NORMAL' for c in l1.rpc.listpeerchannels(l2.info['id'])['channels']]))
1961
1962 fut = executor.submit(l1.rpc.wait, subsystem='channelmoves', indexname='created', nextvalue=1)
1963 l1.daemon.wait_for_log('waiting on channelmoves created 1')
1964 inv = l2.rpc.invoice('any', 'test_wait', 'test_wait')
1965 l1.rpc.xpay(inv['bolt11'], '1000000sat')
1966
1967 out = fut.result(TIMEOUT)
1968 assert out == {'subsystem': 'channelmoves',
1969 'created': 1,
1970 'channelmoves': {'account': fund['channel_id'],
1971 'debit_msat': 1000000000,
1972 'credit_msat': 0}}
1973
1974
1975@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
get_nodesMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
newaddrMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected