Search in sources :

Example 6 with TestSystemProperties

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

the class RemascStorageProviderTest method alwaysPaysFedBeforeRFS.

@Test
public void alwaysPaysFedBeforeRFS() throws IOException {
    RskSystemProperties config = spy(new TestSystemProperties());
    when(config.getActivationConfig()).thenReturn(ActivationConfigsForTest.allBut(ConsensusRule.RSKIP85));
    long minerFee = 21000;
    long txValue = 10000;
    long gasPrice = 1L;
    BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
    RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(minerFee).initialHeight(15).siblingElements(new ArrayList<>()).txSigningKey(this.cowKey).gasPrice(gasPrice);
    testRunner.start();
    Blockchain blockchain = testRunner.getBlockChain();
    RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
    RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
    RemascFederationProvider federationProvider = new RemascFederationProvider(config.getActivationConfig(), config.getNetworkConstants().getBridgeConstants(), repository.startTracking(), testRunner.getBlockChain().getBestBlock());
    assertEquals(Coin.valueOf(0), this.getRemascStorageProvider(repository).getFederationBalance());
    long federatorBalance = (168 / federationProvider.getFederationSize()) * 2;
    assertEquals(Coin.valueOf(federatorBalance), RemascTestRunner.getAccountBalance(repository, federationProvider.getFederatorAddress(0)));
}
Also used : BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) RskSystemProperties(co.rsk.config.RskSystemProperties) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 7 with TestSystemProperties

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

the class RemascStorageProviderTest method paysFedWhenHigherThanMinimumRewardAfterRFS.

@Test
public void paysFedWhenHigherThanMinimumRewardAfterRFS() throws IOException {
    Constants constants = spy(Constants.testnet(null));
    // we need to pass chain id check, and make believe that testnet config has same chain id as cow account
    when(constants.getChainId()).thenReturn(Constants.REGTEST_CHAIN_ID);
    when(constants.getMinimumPayableGas()).thenReturn(BigInteger.valueOf(0));
    when(constants.getFederatorMinimumPayableGas()).thenReturn(BigInteger.valueOf(10L));
    RskSystemProperties config = spy(new TestSystemProperties());
    when(config.getNetworkConstants()).thenReturn(constants);
    long minerFee = 21000;
    long txValue = 10000;
    long gasPrice = 10L;
    BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
    RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(minerFee).initialHeight(15).siblingElements(new ArrayList<>()).txSigningKey(this.cowKey).gasPrice(gasPrice);
    testRunner.start();
    Blockchain blockchain = testRunner.getBlockChain();
    RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
    RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
    RemascFederationProvider federationProvider = new RemascFederationProvider(config.getActivationConfig(), config.getNetworkConstants().getBridgeConstants(), repository.startTracking(), testRunner.getBlockChain().getBestBlock());
    long federatorBalance = (1680 / federationProvider.getFederationSize()) * 2;
    assertEquals(Coin.valueOf(0), this.getRemascStorageProvider(repository).getFederationBalance());
    assertEquals(Coin.valueOf(federatorBalance), RemascTestRunner.getAccountBalance(repository, federationProvider.getFederatorAddress(0)));
}
Also used : Constants(org.ethereum.config.Constants) BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) RskSystemProperties(co.rsk.config.RskSystemProperties) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 8 with TestSystemProperties

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

the class RemascStorageProviderTest method alwaysPaysBeforeRFS.

@Test
public void alwaysPaysBeforeRFS() throws IOException {
    RskSystemProperties config = spy(new TestSystemProperties());
    when(config.getActivationConfig()).thenReturn(ActivationConfigsForTest.allBut(ConsensusRule.RSKIP85));
    long minerFee = 21000;
    long txValue = 10000;
    long gasPrice = 1L;
    BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
    RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(minerFee).initialHeight(15).siblingElements(new ArrayList<>()).txSigningKey(this.cowKey).gasPrice(gasPrice);
    testRunner.start();
    Blockchain blockchain = testRunner.getBlockChain();
    RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
    RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
    this.validateRemascsStorageIsCorrect(this.getRemascStorageProvider(repository), Coin.valueOf(84000), Coin.valueOf(0L), 0L);
}
Also used : BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) RskSystemProperties(co.rsk.config.RskSystemProperties) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 9 with TestSystemProperties

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

the class RemascStorageProviderTest method doesntPayFedBelowMinimumRewardAfterRFS.

@Test
public void doesntPayFedBelowMinimumRewardAfterRFS() throws IOException {
    Constants constants = spy(Constants.testnet(null));
    // we need to pass chain id check, and make believe that testnet config has same chain id as cow account
    when(constants.getChainId()).thenReturn(Constants.REGTEST_CHAIN_ID);
    when(constants.getMinimumPayableGas()).thenReturn(BigInteger.valueOf(0));
    when(constants.getFederatorMinimumPayableGas()).thenReturn(BigInteger.valueOf(10000L));
    RskSystemProperties config = spy(new TestSystemProperties());
    when(config.getNetworkConstants()).thenReturn(constants);
    long minerFee = 21000;
    long txValue = 10000;
    long gasPrice = 1L;
    BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
    RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(minerFee).initialHeight(15).siblingElements(new ArrayList<>()).txSigningKey(this.cowKey).gasPrice(gasPrice);
    testRunner.start();
    Blockchain blockchain = testRunner.getBlockChain();
    RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
    RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
    RemascFederationProvider federationProvider = new RemascFederationProvider(config.getActivationConfig(), config.getNetworkConstants().getBridgeConstants(), repository.startTracking(), testRunner.getBlockChain().getBestBlock());
    assertEquals(Coin.valueOf(336), this.getRemascStorageProvider(repository).getFederationBalance());
    assertEquals(null, RemascTestRunner.getAccountBalance(repository, federationProvider.getFederatorAddress(0)));
}
Also used : Constants(org.ethereum.config.Constants) BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) RskSystemProperties(co.rsk.config.RskSystemProperties) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 10 with TestSystemProperties

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

the class RemascStorageProviderTest method setSaveRetrieveAndGetSiblingsBeforeRFS.

@Test
public void setSaveRetrieveAndGetSiblingsBeforeRFS() throws IOException {
    RskSystemProperties config = spy(new TestSystemProperties());
    when(config.getActivationConfig()).thenReturn(ActivationConfigsForTest.allBut(ConsensusRule.RSKIP85));
    long minerFee = 21000;
    long txValue = 10000;
    BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
    List<SiblingElement> siblings = Arrays.asList(new SiblingElement(5, 6, minerFee), new SiblingElement(10, 11, minerFee));
    RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(minerFee).initialHeight(15).siblingElements(siblings).txSigningKey(this.cowKey);
    testRunner.start();
    Blockchain blockchain = testRunner.getBlockChain();
    RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
    RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
    this.validateRemascsStorageIsCorrect(this.getRemascStorageProvider(repository), Coin.valueOf(0), Coin.valueOf(0L), 1L);
}
Also used : BlockChainBuilder(co.rsk.test.builders.BlockChainBuilder) RskSystemProperties(co.rsk.config.RskSystemProperties) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Aggregations

TestSystemProperties (co.rsk.config.TestSystemProperties)158 Test (org.junit.Test)130 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)109 Blockchain (org.ethereum.core.Blockchain)78 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)75 SimplePeer (co.rsk.net.simples.SimplePeer)69 Block (org.ethereum.core.Block)69 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)56 ConsensusValidationMainchainView (co.rsk.core.bc.ConsensusValidationMainchainView)23 EthereumListener (org.ethereum.listener.EthereumListener)23 BlockStore (org.ethereum.db.BlockStore)21 RskSystemProperties (co.rsk.config.RskSystemProperties)17 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)16 Keccak256 (co.rsk.crypto.Keccak256)13 RepositoryLocator (co.rsk.db.RepositoryLocator)10 World (co.rsk.test.World)10 PrecompiledContracts (org.ethereum.vm.PrecompiledContracts)9 Ignore (org.junit.Ignore)9 TransactionExecutorFactory (co.rsk.core.TransactionExecutorFactory)8 AsyncNodeBlockProcessorListener (co.rsk.net.utils.AsyncNodeBlockProcessorListener)8