### Question:
RemascValidationRule implements BlockValidationRule { @Override public boolean isValid(Block block) { List<Transaction> txs = block.getTransactionsList(); boolean result = CollectionUtils.isNotEmpty(txs) && (txs.get(txs.size()-1) instanceof RemascTransaction); if(!result) { logger.warn("Remasc tx not found in block"); panicProcessor.panic("invalidremasctx", "Remasc tx not found in block"); } return result; }  @Override boolean isValid(Block block);  }### Answer:
@Test public void noTxInTheBlock() { Block b = Mockito.mock(Block.class); RemascValidationRule rule = new RemascValidationRule(); Assert.assertFalse(rule.isValid(b)); }
@Test public void noRemascTxInTheBlock() { Block b = Mockito.mock(Block.class); List<Transaction> tx = new ArrayList<>(); tx.add(Transaction.create(config, "0000000000000000000000000000000000000001", BigInteger.ZERO, BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN)); Mockito.when(b.getTransactionsList()).thenReturn(tx); RemascValidationRule rule = new RemascValidationRule(); Assert.assertFalse(rule.isValid(b)); }
@Test public void remascTxIsNotTheLastOne() { Block b = Mockito.mock(Block.class); List<Transaction> tx = new ArrayList<>(); tx.add(new RemascTransaction(1L)); tx.add(Transaction.create(config, "0000000000000000000000000000000000000001", BigInteger.ZERO, BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN)); Mockito.when(b.getTransactionsList()).thenReturn(tx); RemascValidationRule rule = new RemascValidationRule(); Assert.assertFalse(rule.isValid(b)); }
@Test public void remascTxInBlock() { Block b = Mockito.mock(Block.class); List<Transaction> tx = new ArrayList<>(); tx.add(Transaction.create(config, "0000000000000000000000000000000000000001", BigInteger.ZERO, BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN)); tx.add(new RemascTransaction(1L)); Mockito.when(b.getTransactionsList()).thenReturn(tx); RemascValidationRule rule = new RemascValidationRule(); Assert.assertTrue(rule.isValid(b)); }