use of org.ethereum.db.IndexedBlockStore in project rskj by rsksmart.
the class BlockValidatorTest method invalidUncleAlreadyUsed.
@Test
public void invalidUncleAlreadyUsed() {
IndexedBlockStore store = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Block uncle1a = blockGenerator.createChildBlock(genesis);
Block uncle1b = blockGenerator.createChildBlock(genesis);
List<BlockHeader> uncles1 = new ArrayList<>();
uncles1.add(uncle1a.getHeader());
uncles1.add(uncle1b.getHeader());
Block block1 = blockGenerator.createChildBlock(genesis, null, uncles1, 1, null);
Block uncle2a = blockGenerator.createChildBlock(genesis);
Block uncle2b = blockGenerator.createChildBlock(genesis);
List<BlockHeader> uncles2 = new ArrayList<>();
uncles2.add(uncle2a.getHeader());
uncles2.add(uncle2b.getHeader());
Block block2 = blockGenerator.createChildBlock(block1, null, uncles2, 1, null);
Block block3 = blockGenerator.createChildBlock(block2, null, uncles2, 1, null);
store.saveBlock(genesis, TEST_DIFFICULTY, true);
store.saveBlock(uncle1a, TEST_DIFFICULTY, false);
store.saveBlock(uncle1b, TEST_DIFFICULTY, false);
store.saveBlock(block1, TEST_DIFFICULTY, true);
store.saveBlock(uncle2a, TEST_DIFFICULTY, false);
store.saveBlock(uncle2b, TEST_DIFFICULTY, false);
store.saveBlock(block2, TEST_DIFFICULTY, true);
BlockValidatorImpl validator = new BlockValidatorBuilder().addBlockUnclesValidationRule(store).blockStore(store).build();
Assert.assertFalse(validator.isValid(block3));
}
use of org.ethereum.db.IndexedBlockStore in project rskj by rsksmart.
the class BlockValidatorTest method validateChildBlock.
@Test
public void validateChildBlock() {
IndexedBlockStore blockStore = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
Block genesis = new BlockGenerator().getGenesisBlock();
blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
Block block = new BlockGenerator().createChildBlock(genesis);
BlockValidator validator = createValidator(blockStore);
Assert.assertTrue(validator.isValid(block));
}
use of org.ethereum.db.IndexedBlockStore in project rskj by rsksmart.
the class BlockValidatorTest method getGenesisEmptyAncestorSet.
@Test
public void getGenesisEmptyAncestorSet() {
IndexedBlockStore store = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Assert.assertTrue(FamilyUtils.getAncestors(store, genesis, 6).isEmpty());
}
Aggregations