Search in sources :

Example 86 with BlockHeader

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

the class ParentGasLimitRuleTest method parentGasLimitOfBy1Tests.

// no pass rule
@Test
public void parentGasLimitOfBy1Tests() {
    BlockHeader parent = getHeader(2049);
    BlockHeader headerGGood = getHeader(2051);
    BlockHeader headerGBad = getHeader(2052);
    BlockHeader headerLGood = getHeader(2047);
    BlockHeader headerLBad = getHeader(2046);
    assertTrue(rule.validate(headerGGood, parent));
    assertTrue(rule.validate(headerLGood, parent));
    assertFalse(rule.validate(headerGBad, parent));
    assertFalse(rule.validate(headerLBad, parent));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 87 with BlockHeader

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

the class ParentGasLimitRuleTest method parentGasLimitLessThanGasLimit.

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

Example 88 with BlockHeader

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

the class DifficultyRuleTest method getHeader.

private BlockHeader getHeader(long difficultyValue) {
    byte[] difficulty = DataWord.valueOf(difficultyValue).getData();
    BlockHeader header = blockFactory.getBlockHeaderBuilder().setCoinbase(TestUtils.randomAddress()).setDifficultyFromBytes(difficulty).build();
    return header;
}
Also used : BlockHeader(org.ethereum.core.BlockHeader)

Example 89 with BlockHeader

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

the class DifficultyRuleTest method parentDifficultyEqualHeaderDifficulty.

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

Example 90 with BlockHeader

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

the class ParentNumberRuleTest method parentNumberEqualBlockNumberMinusOne.

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

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