'gasPrice': to_hex(gas_price), 'data': to_hex(function_selector), } request_msg = build_request('eth_call', params=[transaction, 'latest']) 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('net_peerCount'), PeerCountResponse(1), { 'result': '0x1', 'id': 3, 'jsonrpc': '2.0' }, ), ( build_request('net_peerCount'), PeerCountResponse(0), { 'result': '0x0', 'id': 3, 'jsonrpc': '2.0' }, ),
async def mock_event_bus_interaction(bus): async for req in bus.stream(PeerCountRequest): bus.broadcast(PeerCountResponse(count), req.broadcast_config()) break
'to': to_hex(simple_contract_address), 'gasPrice': to_hex(gas_price), 'data': to_hex(function_selector), } request_msg = build_request('eth_call', params=[transaction, 'latest']) 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('net_peerCount'), mock_request_response(PeerCountRequest, PeerCountResponse(1)), {'result': '0x1', 'id': 3, 'jsonrpc': '2.0'}, ), ( build_request('net_peerCount'), mock_request_response(PeerCountRequest, PeerCountResponse(0)), {'result': '0x0', 'id': 3, 'jsonrpc': '2.0'}, ), ), ids=[ 'net_peerCount_1', 'net_peerCount_0', ], ) async def test_peer_pool_over_ipc( jsonrpc_ipc_pipe_path, request_msg,