Search in sources :

Example 91 with RskSystemProperties

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

the class TwoNodeTest method createNode.

private static SimpleNode createNode(int size) {
    final World world = new World();
    final BlockStore store = new BlockStore();
    final Blockchain blockchain = world.getBlockChain();
    List<Block> blocks = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), size);
    for (Block b : blocks) blockchain.tryToConnect(b);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    NodeMessageHandler handler = new NodeMessageHandler(new RskSystemProperties(), processor, null, null, null, null, null, new DummyBlockValidationRule());
    return new SimpleNode(handler);
}
Also used : DummyBlockValidationRule(co.rsk.validators.DummyBlockValidationRule) Blockchain(org.ethereum.core.Blockchain) World(co.rsk.test.World) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) SimpleNode(co.rsk.net.simples.SimpleNode) Block(org.ethereum.core.Block) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration)

Example 92 with RskSystemProperties

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

the class TxValidatorAccountBalanceValidatorTest method balanceIsNotValidatedIfFreeTx.

@Test
public void balanceIsNotValidatedIfFreeTx() {
    Transaction tx = new Transaction(BigInteger.ZERO.toByteArray(), BigInteger.ONE.toByteArray(), BigInteger.valueOf(21071).toByteArray(), new ECKey().getAddress(), BigInteger.ZERO.toByteArray(), Hex.decode("0001"), new RskSystemProperties().getBlockchainConfig().getCommonConstants().getChainId());
    tx.sign(new ECKey().getPrivKeyBytes());
    TxValidatorAccountBalanceValidator tv = new TxValidatorAccountBalanceValidator();
    Assert.assertTrue(tv.validate(tx, new AccountState(), BigInteger.ONE, Coin.valueOf(1L), Long.MAX_VALUE, true));
}
Also used : Transaction(org.ethereum.core.Transaction) ECKey(org.ethereum.crypto.ECKey) AccountState(org.ethereum.core.AccountState) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 93 with RskSystemProperties

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

the class TransactionUtils method createTransaction.

public static Transaction createTransaction(byte[] privateKey, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit) {
    Transaction tx = Transaction.create(new RskSystemProperties(), toAddress, value, nonce, gasPrice, gasLimit);
    tx.sign(privateKey);
    return tx;
}
Also used : Transaction(org.ethereum.core.Transaction) RskSystemProperties(co.rsk.config.RskSystemProperties)

Example 94 with RskSystemProperties

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

the class FileBlockPlayerTest method createPlayer.

@Test
public void createPlayer() throws Exception {
    FileBlockRecorder recorder = new FileBlockRecorder("testblocks.txt");
    recorder.close();
    FileBlockPlayer player = new FileBlockPlayer(new RskSystemProperties(), "testblocks.txt");
    File file = new File("testblocks.txt");
    Assert.assertTrue(file.exists());
    Assert.assertNull(player.readBlock());
    player.close();
    Assert.assertTrue(file.delete());
}
Also used : File(java.io.File) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 95 with RskSystemProperties

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

the class WalletFactory method createPersistentWallet.

public static Wallet createPersistentWallet(String storeName) {
    KeyValueDataSource ds = new LevelDbDataSource(new RskSystemProperties(), storeName);
    ds.init();
    return new Wallet(ds);
}
Also used : KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) LevelDbDataSource(org.ethereum.datasource.LevelDbDataSource) RskSystemProperties(co.rsk.config.RskSystemProperties)

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