Search in sources :

Example 96 with BlockGenerator

use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.

the class BlockTest method sealedBlockHasSealesBlockHeader.

@Test
public void sealedBlockHasSealesBlockHeader() {
    Block block = new BlockGenerator().createBlock(10, 0);
    block.seal();
    Assert.assertTrue(block.getHeader().isSealed());
}
Also used : BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Test(org.junit.Test)

Example 97 with BlockGenerator

use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.

the class BlockTest method sealedBlockHeaderSetTimestamp.

@Test
public void sealedBlockHeaderSetTimestamp() {
    Block block = new BlockGenerator().createBlock(10, 0);
    block.seal();
    try {
        block.getHeader().setTimestamp(10);
        Assert.fail();
    } catch (SealedBlockHeaderException ex) {
        Assert.assertEquals("Sealed block header: trying to alter timestamp", ex.getMessage());
    }
}
Also used : BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Test(org.junit.Test)

Example 98 with BlockGenerator

use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.

the class BlockTest method sealedBlockHeaderSetGasUsed.

@Test
public void sealedBlockHeaderSetGasUsed() {
    Block block = new BlockGenerator().createBlock(10, 0);
    block.seal();
    try {
        block.getHeader().setGasUsed(10);
        Assert.fail();
    } catch (SealedBlockHeaderException ex) {
        Assert.assertEquals("Sealed block header: trying to alter gas used", ex.getMessage());
    }
}
Also used : BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Test(org.junit.Test)

Example 99 with BlockGenerator

use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.

the class BlockTest method sealedBlockHeaderSetBitcoinMergedMiningHeader.

@Test
public void sealedBlockHeaderSetBitcoinMergedMiningHeader() {
    Block block = new BlockGenerator().createBlock(10, 0);
    block.seal();
    try {
        block.getHeader().setBitcoinMergedMiningHeader(new byte[32]);
        Assert.fail();
    } catch (SealedBlockHeaderException ex) {
        Assert.assertEquals("Sealed block header: trying to alter bitcoin merged mining header", ex.getMessage());
    }
}
Also used : BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Test(org.junit.Test)

Example 100 with BlockGenerator

use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.

the class BlockTest method checkTxTrieShouldBeDifferentForDifferentBlock.

@Test
public void checkTxTrieShouldBeDifferentForDifferentBlock() {
    BlockGenerator blockGenerator = new BlockGenerator();
    Block block1 = blockGenerator.createBlock(10, 1);
    Block block2 = blockGenerator.createBlock(10, 2);
    String trieHash1 = Hex.toHexString(block1.getTxTrieRoot());
    String trieHash2 = Hex.toHexString(block2.getTxTrieRoot());
    Assert.assertNotEquals(trieHash1, trieHash2);
}
Also used : BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) Test(org.junit.Test)

Aggregations

BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)250 Test (org.junit.Test)237 Block (org.ethereum.core.Block)104 ArrayList (java.util.ArrayList)39 Blockchain (org.ethereum.core.Blockchain)38 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)36 RskSystemProperties (co.rsk.config.RskSystemProperties)35 SimpleBlock (co.rsk.peg.simples.SimpleBlock)34 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)33 IndexedBlockStore (org.ethereum.db.IndexedBlockStore)31 HashMapDB (org.ethereum.datasource.HashMapDB)22 BlockBuilder (co.rsk.test.builders.BlockBuilder)17 Keccak256 (co.rsk.crypto.Keccak256)15 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)15 BlockStore (org.ethereum.db.BlockStore)15 World (co.rsk.test.World)14 RepositoryImpl (co.rsk.db.RepositoryImpl)13 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)13 Ignore (org.junit.Ignore)12 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)10