use of co.rsk.validators.BlockParentDependantValidationRule in project rskj by rsksmart.
the class BlockValidatorTest method invalidPOWUncles.
@Test
public void invalidPOWUncles() {
IndexedBlockStore store = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
BlockGenerator blockGenerator = new BlockGenerator();
Blockchain blockchain = BlockChainBuilder.ofSize(30, true);
Block genesis = blockchain.getBlockByNumber(0);
Block uncle1a = blockchain.getBlockByNumber(1);
List<BlockHeader> uncles1 = new ArrayList<>();
uncles1.add(uncle1a.getHeader());
Block block1 = blockGenerator.createChildBlock(genesis, null, uncles1, 1, null);
store.saveBlock(genesis, TEST_DIFFICULTY, true);
store.saveBlock(uncle1a, TEST_DIFFICULTY, false);
BlockParentDependantValidationRule parentValidationRule = Mockito.mock(BlockParentDependantValidationRule.class);
Mockito.when(parentValidationRule.isValid(Mockito.any(), Mockito.any())).thenReturn(true);
BlockValidatorImpl validator = new BlockValidatorBuilder().addBlockUnclesValidationRule(store, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), parentValidationRule).blockStore(store).build();
Assert.assertFalse(validator.isValid(block1));
}
Aggregations