Search in sources :

Example 51 with RskSystemProperties

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

the class RemascProcessMinerFeesTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new RegTestConfig());
    remascConfig = new RemascConfigFactory(RemascContract.REMASC_CONFIG).createRemascConfig("regtest");
    accountsAddressesUpToD = new LinkedList<>();
    accountsAddressesUpToD.add(coinbaseA.getBytes());
    accountsAddressesUpToD.add(coinbaseB.getBytes());
    accountsAddressesUpToD.add(coinbaseC.getBytes());
    accountsAddressesUpToD.add(coinbaseD.getBytes());
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) RemascConfigFactory(co.rsk.config.RemascConfigFactory) RskSystemProperties(co.rsk.config.RskSystemProperties) BeforeClass(org.junit.BeforeClass)

Example 52 with RskSystemProperties

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

the class RemascTestRunner method start.

public void start() {
    this.blockchain = this.builder.build();
    ((BlockChainImpl) this.blockchain).setNoValidation(true);
    this.addedSiblings = new ArrayList<>();
    List<Block> mainChainBlocks = new ArrayList<>();
    this.blockchain.tryToConnect(this.genesis);
    BlockExecutor blockExecutor = new BlockExecutor(new RskSystemProperties(), blockchain.getRepository(), null, blockchain.getBlockStore(), null);
    for (int i = 0; i <= this.initialHeight; i++) {
        int finalI = i;
        List<SiblingElement> siblingsForCurrentHeight = this.siblingElements.stream().filter(siblingElement -> siblingElement.getHeightToBeIncluded() == finalI).collect(Collectors.toList());
        List<BlockHeader> blockSiblings = new ArrayList<>();
        // Going to add siblings
        BlockDifficulty cummDifficulty = BlockDifficulty.ZERO;
        if (siblingsForCurrentHeight.size() > 0) {
            cummDifficulty = blockchain.getTotalDifficulty();
        }
        for (SiblingElement sibling : siblingsForCurrentHeight) {
            RskAddress siblingCoinbase = TestUtils.randomAddress();
            Block mainchainSiblingParent = mainChainBlocks.get(sibling.getHeight() - 1);
            Block siblingBlock = createBlock(this.genesis, mainchainSiblingParent, PegTestUtils.createHash3(), siblingCoinbase, null, minerFee, Long.valueOf(i), this.txValue, this.txSigningKey, null);
            blockSiblings.add(siblingBlock.getHeader());
            blockchain.getBlockStore().saveBlock(siblingBlock, cummDifficulty.add(siblingBlock.getCumulativeDifficulty()), false);
            this.addedSiblings.add(siblingBlock);
        }
        long txNonce = i;
        RskAddress coinbase = TestUtils.randomAddress();
        Block block = createBlock(this.genesis, this.blockchain.getBestBlock(), PegTestUtils.createHash3(), coinbase, blockSiblings, minerFee, txNonce, this.txValue, this.txSigningKey, null);
        mainChainBlocks.add(block);
        blockExecutor.executeAndFillAll(block, this.blockchain.getBestBlock());
        block.seal();
        ImportResult result = this.blockchain.tryToConnect(block);
        System.out.println(result);
    }
}
Also used : BlockDifficulty(co.rsk.core.BlockDifficulty) BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) TestUtils(org.ethereum.TestUtils) HashUtil(org.ethereum.crypto.HashUtil) RLP(org.ethereum.util.RLP) RskAddress(co.rsk.core.RskAddress) BlockExecutor(co.rsk.core.bc.BlockExecutor) Coin(co.rsk.core.Coin) PegTestUtils(co.rsk.peg.PegTestUtils) Keccak256(co.rsk.crypto.Keccak256) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) BigInteger(java.math.BigInteger) RskSystemProperties(co.rsk.config.RskSystemProperties) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) org.ethereum.core(org.ethereum.core) ECKey(org.ethereum.crypto.ECKey) BlockExecutor(co.rsk.core.bc.BlockExecutor) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) ArrayList(java.util.ArrayList) BlockDifficulty(co.rsk.core.BlockDifficulty) RskAddress(co.rsk.core.RskAddress) RskSystemProperties(co.rsk.config.RskSystemProperties)

Example 53 with RskSystemProperties

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

the class ModuleDescriptionTest method getModulesFromTestNewRskSystemProperties.

@Test
public void getModulesFromTestNewRskSystemProperties() {
    RskSystemProperties config = new RskSystemProperties();
    List<ModuleDescription> modules = config.getRpcModules();
    Assert.assertNotNull(modules);
    Assert.assertFalse(modules.isEmpty());
    Assert.assertEquals(2, modules.size());
    ModuleDescription moduleEth = modules.get(0);
    Assert.assertEquals("eth", moduleEth.getName());
    Assert.assertEquals("1.0", moduleEth.getVersion());
    Assert.assertTrue(moduleEth.isEnabled());
    Assert.assertNotNull(moduleEth.getEnabledMethods());
    Assert.assertTrue(moduleEth.getEnabledMethods().isEmpty());
    Assert.assertNotNull(moduleEth.getDisabledMethods());
    Assert.assertTrue(moduleEth.getDisabledMethods().isEmpty());
    ModuleDescription moduleEvm = modules.get(1);
    Assert.assertEquals("evm", moduleEvm.getName());
    Assert.assertEquals("1.1", moduleEvm.getVersion());
    Assert.assertFalse(moduleEvm.isEnabled());
    Assert.assertNotNull(moduleEvm.getEnabledMethods());
    Assert.assertFalse(moduleEvm.getEnabledMethods().isEmpty());
    Assert.assertEquals(2, moduleEvm.getEnabledMethods().size());
    Assert.assertNotNull(moduleEvm.getDisabledMethods());
    Assert.assertFalse(moduleEvm.getDisabledMethods().isEmpty());
    Assert.assertEquals(2, moduleEvm.getDisabledMethods().size());
}
Also used : RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 54 with RskSystemProperties

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

the class Web3ImplRpcTest method getRpcModules.

@Test
public void getRpcModules() {
    Ethereum eth = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    PersonalModule pm = new PersonalModuleWalletDisabled();
    Repository repository = Web3Mocks.getMockRepository();
    Web3Impl web3 = new Web3RskImpl(eth, blockchain, transactionPool, new RskSystemProperties(), null, null, pm, null, null, null, repository, null, null, null, null, null, null, null, null);
    Map<String, String> result = web3.rpc_modules();
    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
    Assert.assertTrue(result.containsKey("eth"));
    Assert.assertEquals("1.0", result.get("eth"));
}
Also used : TransactionPool(org.ethereum.core.TransactionPool) Repository(org.ethereum.core.Repository) Ethereum(org.ethereum.facade.Ethereum) Blockchain(org.ethereum.core.Blockchain) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) Web3Impl(org.ethereum.rpc.Web3Impl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 55 with RskSystemProperties

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

the class TxValidatorIntrinsicGasLimitValidatorTest method setUp.

@Before
public void setUp() {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new RegTestConfig());
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) RskSystemProperties(co.rsk.config.RskSystemProperties) Before(org.junit.Before)

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