Beispiel #1
0
 async def mock_event_bus_interaction(bus):
     async for req in bus.stream(SyncingRequest):
         bus.broadcast(SyncingResponse(is_syncing, progress),
                       req.broadcast_config())
         break
Beispiel #2
0
        result = await get_ipc_response(
            jsonrpc_ipc_pipe_path,
            request_msg,
            event_loop,
            event_bus,
        )
        assert result == expected


@pytest.mark.asyncio
@pytest.mark.parametrize(
    'request_msg, event_bus_response, expected',
    (
        (
            build_request('eth_syncing'),
            SyncingResponse(False, None),
            {
                'result': False,
                'id': 3,
                'jsonrpc': '2.0'
            },
        ),
        (
            build_request('eth_syncing'),
            SyncingResponse(True, SyncProgress(0, 1, 2)),
            {
                'result': {
                    'startingBlock': 0,
                    'currentBlock': 1,
                    'highestBlock': 2
                },
Beispiel #3
0
 async def _handle_sync_status_requests(self,
                                        event_bus: EndpointAPI) -> None:
     async for req in self.wait_iter(event_bus.stream(SyncingRequest)):
         await event_bus.broadcast(
             SyncingResponse(*self._get_sync_status()),
             req.broadcast_config())
Beispiel #4
0
    result = await get_ipc_response(
        jsonrpc_ipc_pipe_path,
        request_msg,
        event_loop,
        event_bus,
    )
    assert result == expected


@pytest.mark.asyncio
@pytest.mark.parametrize(
    'request_msg, event_bus_setup_fn, expected',
    (
        (
            build_request('eth_syncing'),
            mock_request_response(SyncingRequest, SyncingResponse(False, None)),
            {'result': False, 'id': 3, 'jsonrpc': '2.0'},
        ),
        (
            build_request('eth_syncing'),
            mock_request_response(SyncingRequest, SyncingResponse(True, SyncProgress(0, 1, 2))),
            {'result': {'startingBlock': 0, 'currentBlock': 1, 'highestBlock': 2}, 'id': 3,
             'jsonrpc': '2.0'},
        ),
    ),
    ids=[
        'eth_syncing_F', 'eth_syncing_T',
    ],
)
async def test_eth_over_ipc(
        jsonrpc_ipc_pipe_path,
Beispiel #5
0
 async def handle_sync_status_requests(self) -> None:
     async for req in self.peer_pool.event_bus.stream(SyncingRequest):
         self.peer_pool.event_bus.broadcast(SyncingResponse(*self.get_sync_status()),
                                            req.broadcast_config())