### Question:
TxValidatorGasLimitValidator implements TxValidatorStep { @Override public boolean validate(Transaction tx, @Nullable AccountState state, BigInteger gasLimit, Coin minimumGasPrice, long bestBlockNumber, boolean isFreeTx) { BigInteger txGasLimit = tx.getGasLimitAsInteger(); if (txGasLimit.compareTo(gasLimit) <= 0 && txGasLimit.compareTo(Constants.getTransactionGasCap()) <= 0) { return true; } logger.warn("Invalid transaction {}: its gas limit {} is higher than the block gas limit {}", tx.getHash(), txGasLimit, gasLimit); return false; }  @Override boolean validate(Transaction tx, @Nullable AccountState state, BigInteger gasLimit, Coin minimumGasPrice, long bestBlockNumber, boolean isFreeTx);  }### Answer:
@Test public void validGasLimit() { Transaction tx1 = Mockito.mock(Transaction.class); Transaction tx2 = Mockito.mock(Transaction.class); Mockito.when(tx1.getGasLimitAsInteger()).thenReturn(BigInteger.valueOf(1)); Mockito.when(tx2.getGasLimitAsInteger()).thenReturn(BigInteger.valueOf(6)); BigInteger gl = BigInteger.valueOf(6); TxValidatorGasLimitValidator tvglv = new TxValidatorGasLimitValidator(); Assert.assertTrue(tvglv.validate(tx1, null, gl, null, Long.MAX_VALUE, false)); Assert.assertTrue(tvglv.validate(tx2, null, gl, null, Long.MAX_VALUE, false)); }
@Test public void invalidGasLimit() { Transaction tx1 = Mockito.mock(Transaction.class); Mockito.when(tx1.getGasLimitAsInteger()).thenReturn(BigInteger.valueOf(6)); Mockito.when(tx1.getHash()).thenReturn(Keccak256.ZERO_HASH); BigInteger gl = BigInteger.valueOf(3); TxValidatorGasLimitValidator tvglv = new TxValidatorGasLimitValidator(); Assert.assertFalse(tvglv.validate(tx1, null, gl, null, Long.MAX_VALUE, false)); }