### Question:
ExtCodeHashOperation extends AbstractOperation { @Override public OperationResult execute(final MessageFrame frame, final EVM evm) { try { final Address address = Words.toAddress(frame.popStackItem()); final boolean accountIsWarm = frame.warmUpAddress(address) || gasCalculator().isPrecompile(address); final Optional<Gas> optionalCost = accountIsWarm ? warmCost : coldCost; if (frame.getRemainingGas().compareTo(optionalCost.get()) < 0) { return new OperationResult( optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS)); } else { final Account account = frame.getWorldState().get(address); if (account == null || account.isEmpty()) { frame.pushStackItem(Bytes32.ZERO); } else { frame.pushStackItem(account.getCodeHash()); } return new OperationResult(optionalCost, Optional.empty()); } } catch (final UnderflowException ufe) { return new OperationResult( warmCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_STACK_ITEMS)); } catch (final OverflowException ofe) { return new OperationResult(warmCost, Optional.of(ExceptionalHaltReason.TOO_MANY_STACK_ITEMS)); } } ExtCodeHashOperation(final GasCalculator gasCalculator); @Override OperationResult execute(final MessageFrame frame, final EVM evm);  }### Answer:
@Test public void shouldCharge400Gas() { final OperationResult result = operation.execute(createMessageFrame(REQUESTED_ADDRESS), null); assertThat(result.getGasCost()).contains(Gas.of(400)); }
@Test public void istanbulShouldCharge700Gas() { final OperationResult result = operationIstanbul.execute(createMessageFrame(REQUESTED_ADDRESS), null); assertThat(result.getGasCost()).contains(Gas.of(700)); }
@Test public void shouldZeroOutLeftMostBitsToGetAddress() { final Bytes code = Bytes.fromHexString("0xabcdef"); final MutableAccount account = worldStateUpdater.getOrCreate(REQUESTED_ADDRESS).getMutable(); account.setCode(code); account.setVersion(Account.DEFAULT_VERSION); final Bytes32 value = UInt256.fromBytes(Words.fromAddress(REQUESTED_ADDRESS)) .add(UInt256.valueOf(2).pow(UInt256.valueOf(160))) .toBytes(); final MessageFrame frame = createMessageFrame(value); operation.execute(frame, null); assertThat(frame.getStackItem(0)).isEqualTo(Hash.hash(code)); }