Search in sources :

Example 16 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)

Example 17 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)

Example 18 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(long gasLimitValue) {
    byte[] gasLimit = new DataWord(gasLimitValue).getData();
    BlockHeader header = new BlockHeader(null, null, RskAddress.nullAddress().getBytes(), null, BlockDifficulty.ZERO.getBytes(), 0, gasLimit, 0, 0, null, null, 0);
    return header;
}
Also used : DataWord(org.ethereum.vm.DataWord) BlockHeader(org.ethereum.core.BlockHeader)

Example 19 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)

Example 20 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)

Aggregations

BlockHeader (org.ethereum.core.BlockHeader)65 Test (org.junit.Test)36 Block (org.ethereum.core.Block)27 ArrayList (java.util.ArrayList)13 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)9 BlockDifficulty (co.rsk.core.BlockDifficulty)5 Keccak256 (co.rsk.crypto.Keccak256)5 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)4 BlockBuilder (co.rsk.test.builders.BlockBuilder)4 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)4 BlockStore (org.ethereum.db.BlockStore)4 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)3 BigInteger (java.math.BigInteger)3 MainNetConfig (org.ethereum.config.net.MainNetConfig)3 DataWord (org.ethereum.vm.DataWord)3 DifficultyCalculator (co.rsk.core.DifficultyCalculator)2 BlockChainImplTest (co.rsk.core.bc.BlockChainImplTest)2 HashSet (java.util.HashSet)2 Bloom (org.ethereum.core.Bloom)2 Transaction (org.ethereum.core.Transaction)2