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)));
}
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)));
}
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);
}
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)));
}
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);
}
Aggregations