Search in sources :

Example 81 with BlockHeader

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));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test)

Example 82 with BlockHeader

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));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test)

Example 83 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class BlockTxsValidationRuleTest method setup.

@Before
public void setup() {
    parent = mock(Block.class);
    BlockHeader parentHeader = mock(BlockHeader.class);
    when(parent.getHeader()).thenReturn(parentHeader);
    RepositoryLocator repositoryLocator = mock(RepositoryLocator.class);
    repositorySnapshot = mock(RepositorySnapshot.class);
    when(repositoryLocator.snapshotAt(parentHeader)).thenReturn(repositorySnapshot);
    rule = new BlockTxsValidationRule(repositoryLocator);
}
Also used : RepositoryLocator(co.rsk.db.RepositoryLocator) RepositorySnapshot(co.rsk.db.RepositorySnapshot) Block(org.ethereum.core.Block) BlockHeader(org.ethereum.core.BlockHeader) Before(org.junit.Before)

Example 84 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class ParentGasLimitRuleTest method parentGasLimitGreaterThanGasLimit.

// pass rule
@Test
public void parentGasLimitGreaterThanGasLimit() {
    BlockHeader header = getHeader(10000);
    BlockHeader parent = getHeader(10001);
    assertTrue(rule.validate(header, parent));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 85 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class ParentGasLimitRuleTest method getHeader.

// Used also by GasLimitCalculatorTest
public static BlockHeader getHeader(BlockFactory blockFactory, long gasLimitValue) {
    byte[] gasLimit = DataWord.valueOf(gasLimitValue).getData();
    BlockHeader header = blockFactory.getBlockHeaderBuilder().setCoinbase(TestUtils.randomAddress()).setDifficulty(BlockDifficulty.ZERO).setGasLimit(gasLimit).build();
    return header;
}
Also used : BlockHeader(org.ethereum.core.BlockHeader)

Aggregations

BlockHeader (org.ethereum.core.BlockHeader)189 Test (org.junit.Test)128 Block (org.ethereum.core.Block)83 Keccak256 (co.rsk.crypto.Keccak256)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)30 ArrayList (java.util.ArrayList)23 BlockStore (org.ethereum.db.BlockStore)21 RLPList (org.ethereum.util.RLPList)20 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)14 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)9 BlockDifficulty (co.rsk.core.BlockDifficulty)7 ConsensusValidationMainchainView (co.rsk.core.bc.ConsensusValidationMainchainView)7 ForkDetectionDataCalculator (co.rsk.mine.ForkDetectionDataCalculator)7 BigInteger (java.math.BigInteger)7 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)6 SimplePeer (co.rsk.net.simples.SimplePeer)6 BlockBuilder (co.rsk.test.builders.BlockBuilder)6 Trie (co.rsk.trie.Trie)4 Before (org.junit.Before)4 DifficultyCalculator (co.rsk.core.DifficultyCalculator)3