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)
| 585 | |
| 586 | |
| 587 | def 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") |