Search in sources :

Example 1 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class BridgeSupportTest method setUpOnEachTest.

@Before
public void setUpOnEachTest() {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new RegTestConfig());
    bridgeConstants = config.getBlockchainConfig().getCommonConstants().getBridgeConstants();
    btcParams = bridgeConstants.getBtcParams();
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) RskSystemProperties(co.rsk.config.RskSystemProperties) Before(org.junit.Before)

Example 2 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class BridgeSupportTest method testInitialChainHeadWithBtcCheckpoints.

@Test
public void testInitialChainHeadWithBtcCheckpoints() throws Exception {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new TestNetConfig());
    bridgeConstants = config.getBlockchainConfig().getCommonConstants().getBridgeConstants();
    btcParams = bridgeConstants.getBtcParams();
    Repository repository = new RepositoryImpl(config);
    Repository track = repository.startTracking();
    BridgeStorageProvider provider = new BridgeStorageProvider(track, PrecompiledContracts.BRIDGE_ADDR, config.getBlockchainConfig().getCommonConstants().getBridgeConstants());
    BridgeSupport bridgeSupport = new BridgeSupport(config, track, mock(BridgeEventLogger.class), provider, null);
    Assert.assertEquals(1229760, bridgeSupport.getBtcBlockStore().getChainHead().getHeight());
}
Also used : TestNetConfig(org.ethereum.config.net.TestNetConfig) RepositoryImpl(co.rsk.db.RepositoryImpl) RskSystemProperties(co.rsk.config.RskSystemProperties) BridgeEventLogger(co.rsk.peg.utils.BridgeEventLogger) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class MainNetMinerTest method setup.

@Before
public void setup() {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new FallbackMainNetConfig());
    DIFFICULTY_CALCULATOR = new DifficultyCalculator(config);
    World world = new World();
    blockchain = world.getBlockChain();
}
Also used : DifficultyCalculator(co.rsk.core.DifficultyCalculator) FallbackMainNetConfig(org.ethereum.config.blockchain.FallbackMainNetConfig) World(co.rsk.test.World) RskSystemProperties(co.rsk.config.RskSystemProperties) Before(org.junit.Before)

Example 4 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class BlockSyncServiceTest method sendBlockMessagesAndAddThemToBlockchainInReverseOrder.

@Test
public void sendBlockMessagesAndAddThemToBlockchainInReverseOrder() {
    for (int i = 1; i < 52; i += 5) {
        Blockchain blockchain = BlockChainBuilder.ofSize(10 * i);
        BlockStore store = new BlockStore();
        BlockNodeInformation nodeInformation = new BlockNodeInformation();
        RskSystemProperties config = new RskSystemProperties();
        BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING);
        Assert.assertEquals(10 * i, blockchain.getBestBlock().getNumber());
        Block initialBestBlock = blockchain.getBestBlock();
        List<Block> extendedChain = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), i);
        Collections.reverse(extendedChain);
        for (int j = 0; j < extendedChain.size() - 1; j++) {
            Block block = extendedChain.get(j);
            blockSyncService.processBlock(block, null, false);
            // we don't have all the parents, so we wait to update the best chain
            Assert.assertEquals(initialBestBlock.getNumber(), blockchain.getBestBlock().getNumber());
            Assert.assertEquals(initialBestBlock.getHash(), blockchain.getBestBlock().getHash());
        }
        // the chain is complete, we have a new best block
        Block closingBlock = extendedChain.get(extendedChain.size() - 1);
        Block newBestBlock = extendedChain.get(0);
        blockSyncService.processBlock(closingBlock, null, false);
        Assert.assertEquals(newBestBlock.getNumber(), blockchain.getBestBlock().getNumber());
        Assert.assertEquals(newBestBlock.getHash(), blockchain.getBestBlock().getHash());
    }
}
Also used : Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 5 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method advancedBlock.

@Test
public void advancedBlock() throws UnknownHostException {
    final BlockStore store = new BlockStore();
    final MessageChannel sender = new SimpleMessageChannel();
    final BlockNodeInformation nodeInformation = new BlockNodeInformation();
    final SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    final Blockchain blockchain = BlockChainBuilder.ofSize(0);
    final long advancedBlockNumber = syncConfiguration.getChunkSize() * syncConfiguration.getMaxSkeletonChunks() + blockchain.getBestBlock().getNumber() + 1;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    Assert.assertTrue(processor.isAdvancedBlock(advancedBlockNumber));
    Assert.assertFalse(processor.isAdvancedBlock(advancedBlockNumber - 1));
}
Also used : SimpleMessageChannel(co.rsk.net.simples.SimpleMessageChannel) SimpleMessageChannel(co.rsk.net.simples.SimpleMessageChannel) Blockchain(org.ethereum.core.Blockchain) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Aggregations

RskSystemProperties (co.rsk.config.RskSystemProperties)112 Test (org.junit.Test)81 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)48 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)45 Blockchain (org.ethereum.core.Blockchain)45 Block (org.ethereum.core.Block)41 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)35 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)20 Ignore (org.junit.Ignore)10 Keccak256 (co.rsk.crypto.Keccak256)8 RegTestConfig (org.ethereum.config.blockchain.RegTestConfig)8 Repository (org.ethereum.core.Repository)8 SimpleChannelManager (org.ethereum.rpc.Simples.SimpleChannelManager)8 Channel (org.ethereum.net.server.Channel)7 ChannelManager (org.ethereum.net.server.ChannelManager)7 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 BlockDifficulty (co.rsk.core.BlockDifficulty)6 RskAddress (co.rsk.core.RskAddress)6 PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)6 BeforeClass (org.junit.BeforeClass)6