use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class RskCustomCacheTest method addElement.
@Test
public void addElement() {
RskCustomCache cache = new RskCustomCache(TIME_TO_LIVE);
BlockHeader header1 = Mockito.mock(BlockHeader.class);
cache.put(KEY, header1);
Assert.assertNotNull(cache.get(KEY));
Assert.assertEquals(header1, cache.get(KEY));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class RskCustomCacheTest method getElement.
@Test
public void getElement() {
RskCustomCache cache = new RskCustomCache(TIME_TO_LIVE);
BlockHeader header1 = Mockito.mock(BlockHeader.class);
cache.put(KEY, header1);
Assert.assertNotNull(cache.get(KEY));
Assert.assertNull(cache.get(OTHER_KEY));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class BlockUnclesValidationRuleTest method rejectBlockWithSiblingUncle.
@Test
public void rejectBlockWithSiblingUncle() {
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Block block1 = blockGenerator.createChildBlock(genesis);
Block uncle = blockGenerator.createChildBlock(block1);
List<BlockHeader> uncles = new ArrayList<>();
uncles.add(uncle.getHeader());
Block block = blockGenerator.createChildBlock(block1, null, uncles, 1, null);
BlockChainImpl blockChain = BlockChainImplTest.createBlockChain();
BlockStore store = blockChain.getBlockStore();
store.saveBlock(genesis, new BlockDifficulty(BigInteger.valueOf(1)), true);
store.saveBlock(block1, new BlockDifficulty(BigInteger.valueOf(2)), true);
BlockUnclesValidationRule rule = new BlockUnclesValidationRule(config, store, 10, 10, new BlockCompositeRule(), new BlockParentCompositeRule());
Assert.assertFalse(rule.isValid(block));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ExtraDataRuleTests method blockWithValidLongerExtraDataThanAccepted.
@Test
public void blockWithValidLongerExtraDataThanAccepted() {
BlockHeader blockHeader = Mockito.mock(BlockHeader.class);
Mockito.when(blockHeader.getExtraData()).thenReturn(new byte[43]);
Block block = new Block(blockHeader);
ExtraDataRule rule = new ExtraDataRule(42);
Assert.assertFalse(rule.isValid(block));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ExtraDataRuleTests method blockWithValidExtraData.
@Test
public void blockWithValidExtraData() {
BlockHeader blockHeader = Mockito.mock(BlockHeader.class);
Mockito.when(blockHeader.getExtraData()).thenReturn(new byte[32]);
Block block = new Block(blockHeader);
ExtraDataRule rule = new ExtraDataRule(42);
Assert.assertTrue(rule.isValid(block));
}
Aggregations