use of co.rsk.validators.BlockHeaderParentDependantValidationRule in project rskj by rsksmart.
the class BlockValidatorTest method invalidPOWUncles.
@Test
public void invalidPOWUncles() {
IndexedBlockStore store = new IndexedBlockStore(blockFactory, new HashMapDB(), new HashMapBlocksIndex());
BlockGenerator blockGenerator = new BlockGenerator();
Blockchain blockchain = new 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);
BlockHeaderParentDependantValidationRule parentValidationRule = mock(BlockHeaderParentDependantValidationRule.class);
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