Search in sources :

Example 1 with TestNetConfig

use of org.ethereum.config.net.TestNetConfig 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 2 with TestNetConfig

use of org.ethereum.config.net.TestNetConfig in project rskj by rsksmart.

the class SystemProperties method getBlockchainConfig.

@ValidateMe
public BlockchainNetConfig getBlockchainConfig() {
    if (blockchainConfig == null) {
        String netName = netName();
        if (netName != null && configFromFiles.hasPath("blockchain.config.class")) {
            throw new RuntimeException("Only one of two options should be defined: 'blockchain.config.name' and 'blockchain.config.class'");
        }
        if (netName != null) {
            switch(netName) {
                case "main":
                    blockchainConfig = new MainNetConfig();
                    break;
                case "fallbackmain":
                    blockchainConfig = new FallbackMainNetConfig();
                    break;
                case "testnet":
                    blockchainConfig = new TestNetConfig();
                    break;
                case "devnet":
                    blockchainConfig = new DevNetConfig();
                    break;
                case "regtest":
                    blockchainConfig = new RegTestConfig();
                    break;
                default:
                    throw new RuntimeException("Unknown value for 'blockchain.config.name': '" + configFromFiles.getString("blockchain.config.name") + "'");
            }
        } else {
            String className = configFromFiles.getString("blockchain.config.class");
            try {
                Class<? extends BlockchainNetConfig> aClass = (Class<? extends BlockchainNetConfig>) Class.forName(className);
                blockchainConfig = aClass.newInstance();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException("The class specified via blockchain.config.class '" + className + "' not found", e);
            } catch (ClassCastException e) {
                throw new RuntimeException("The class specified via blockchain.config.class '" + className + "' is not instance of org.ethereum.config.BlockchainForkConfig", e);
            } catch (InstantiationException | IllegalAccessException e) {
                throw new RuntimeException("The class specified via blockchain.config.class '" + className + "' couldn't be instantiated (check for default constructor and its accessibility)", e);
            }
        }
    }
    return blockchainConfig;
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) FallbackMainNetConfig(org.ethereum.config.blockchain.FallbackMainNetConfig) DevNetConfig(org.ethereum.config.blockchain.DevNetConfig) TestNetConfig(org.ethereum.config.net.TestNetConfig) FallbackMainNetConfig(org.ethereum.config.blockchain.FallbackMainNetConfig) MainNetConfig(org.ethereum.config.net.MainNetConfig)

Aggregations

TestNetConfig (org.ethereum.config.net.TestNetConfig)2 RskSystemProperties (co.rsk.config.RskSystemProperties)1 RepositoryImpl (co.rsk.db.RepositoryImpl)1 BridgeEventLogger (co.rsk.peg.utils.BridgeEventLogger)1 DevNetConfig (org.ethereum.config.blockchain.DevNetConfig)1 FallbackMainNetConfig (org.ethereum.config.blockchain.FallbackMainNetConfig)1 RegTestConfig (org.ethereum.config.blockchain.RegTestConfig)1 MainNetConfig (org.ethereum.config.net.MainNetConfig)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1