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

Function test_async_rpcmethod

tests/test_plugin.py:587–608  ·  view source on GitHub ↗

This tests the async rpcmethods. It works in conjunction with the `asynctest` plugin which stashes requests and then resolves all of them on the fifth call.

(node_factory, executor)

Source from the content-addressed store, hash-verified

585
586
587def test_async_rpcmethod(node_factory, executor):
588 """This tests the async rpcmethods.
589
590 It works in conjunction with the `asynctest` plugin which stashes
591 requests and then resolves all of them on the fifth call.
592 """
593 l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/asynctest.py')})
594
595 results = []
596 for i in range(10):
597 results.append(executor.submit(l1.rpc.asyncqueue))
598
599 time.sleep(3)
600
601 # None of these should have returned yet
602 assert len([r for r in results if r.done()]) == 0
603
604 # This last one triggers the release and all results should be 42,
605 # since the last number is returned for all
606 l1.rpc.asyncflush(42)
607
608 assert [r.result() for r in results] == [42] * len(results)
609
610
611@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Only sqlite3 implements the db_write_hook currently")

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
get_nodeMethod · 0.45

Tested by

no test coverage detected