### Question:
EthGetWork implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { final Optional<EthHashSolverInputs> solver = miner.getWorkDefinition(); if (solver.isPresent()) { final EthHashSolverInputs rawResult = solver.get(); final byte[] dagSeed = DirectAcyclicGraphSeed.dagSeed(rawResult.getBlockNumber()); final String[] result = { "0x" + BaseEncoding.base16().lowerCase().encode(rawResult.getPrePowHash()), "0x" + BaseEncoding.base16().lowerCase().encode(dagSeed), rawResult.getTarget().toHexString(), Quantity.create(rawResult.getBlockNumber()) }; return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result); } else { LOG.trace("Mining is not operational, eth_getWork request cannot be processed"); return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.NO_MINING_WORK_FOUND); } } EthGetWork(final MiningCoordinator miner); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnCorrectResultOnGenesisDAG() { final JsonRpcRequestContext request = requestWithParams(); final EthHashSolverInputs values = new EthHashSolverInputs( UInt256.fromHexString(hexValue), BaseEncoding.base16().lowerCase().decode(hexValue), 0); final String[] expectedValue = { "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0x0000000000000000000000000000000000000000000000000000000000000000", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0x0" }; final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedValue); when(miningCoordinator.getWorkDefinition()).thenReturn(Optional.of(values)); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void shouldReturnCorrectResultOnHighBlockSeed() { final JsonRpcRequestContext request = requestWithParams(); final EthHashSolverInputs values = new EthHashSolverInputs( UInt256.fromHexString(hexValue), BaseEncoding.base16().lowerCase().decode(hexValue), 30000); final String[] expectedValue = { "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0x" + BaseEncoding.base16().lowerCase().encode(DirectAcyclicGraphSeed.dagSeed(30000)), "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0x7530" }; final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedValue); when(miningCoordinator.getWorkDefinition()).thenReturn(Optional.of(values)); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void shouldReturnErrorOnNoneMiningNode() { final JsonRpcRequestContext request = requestWithParams(); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.NO_MINING_WORK_FOUND); when(miningCoordinator.getWorkDefinition()).thenReturn(Optional.empty()); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }