Search in sources :

Example 6 with RegTestConfig

use of org.ethereum.config.blockchain.RegTestConfig in project rskj by rsksmart.

the class TxValidatorTest method brigdeTxTest.

@Test
public void brigdeTxTest() {
    config.setBlockchainConfig(new RegTestConfig());
    List<Transaction> txs = new LinkedList<>();
    // Bridge Tx
    txs.add(createBridgeTx(config, 1, 0, 1, 0, 0, 6));
    Repository repository = Mockito.mock(Repository.class);
    final long blockGasLimit = 100000;
    Blockchain blockchain = Mockito.mock(Blockchain.class);
    Block block = Mockito.mock(Block.class);
    Mockito.when(blockchain.getBestBlock()).thenReturn(block);
    Mockito.when(block.getGasLimit()).thenReturn(BigInteger.valueOf(blockGasLimit).toByteArray());
    Mockito.when(block.getMinimumGasPrice()).thenReturn(Coin.valueOf(1L));
    createAccountState(txs.get(0), repository, 0, 0);
    TxValidator txValidator = new TxValidator(config, repository, blockchain);
    List<Transaction> result = txValidator.filterTxs(txs);
    Assert.assertTrue(result.size() == 1);
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) Test(org.junit.Test)

Example 7 with RegTestConfig

use of org.ethereum.config.blockchain.RegTestConfig 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)

Example 8 with RegTestConfig

use of org.ethereum.config.blockchain.RegTestConfig 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)

Example 9 with RegTestConfig

use of org.ethereum.config.blockchain.RegTestConfig in project rskj by rsksmart.

the class BridgeUtilsTest method isFreeBridgeTxFreeTxDisabled.

@Test
public void isFreeBridgeTxFreeTxDisabled() {
    config.setBlockchainConfig(new RegTestConfig() {

        @Override
        public boolean areBridgeTxsFree() {
            return false;
        }
    });
    isFreeBridgeTx(false, PrecompiledContracts.BRIDGE_ADDR, BridgeRegTestConstants.getInstance().getFederatorPrivateKeys().get(0).getPrivKeyBytes());
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) Test(org.junit.Test)

Example 10 with RegTestConfig

use of org.ethereum.config.blockchain.RegTestConfig in project rskj by rsksmart.

the class RskForksBridgeTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    config = new RskSystemProperties();
    config.setBlockchainConfig(new RegTestConfig());
}
Also used : RegTestConfig(org.ethereum.config.blockchain.RegTestConfig) RskSystemProperties(co.rsk.config.RskSystemProperties) BeforeClass(org.junit.BeforeClass)

Aggregations

RegTestConfig (org.ethereum.config.blockchain.RegTestConfig)12 RskSystemProperties (co.rsk.config.RskSystemProperties)8 BeforeClass (org.junit.BeforeClass)7 RemascConfigFactory (co.rsk.config.RemascConfigFactory)2 Before (org.junit.Before)2 Test (org.junit.Test)2 DevNetConfig (org.ethereum.config.blockchain.DevNetConfig)1 FallbackMainNetConfig (org.ethereum.config.blockchain.FallbackMainNetConfig)1 MainNetConfig (org.ethereum.config.net.MainNetConfig)1 TestNetConfig (org.ethereum.config.net.TestNetConfig)1