use of co.rsk.core.bc.TransactionPoolImpl in project rskj by rsksmart.
the class Web3ImplLogsTest method getWeb3WithContractInvoke.
private Web3Impl getWeb3WithContractInvoke() {
ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
World world = new World(receiptStore);
Account acc1 = new AccountBuilder(world).name("notDefault").balance(Coin.valueOf(10000000)).build();
Block genesis = world.getBlockByName("g00");
Transaction tx;
tx = getContractTransaction(acc1);
List<Transaction> txs = new ArrayList<>();
txs.add(tx);
BlockChainImpl blockChain = world.getBlockChain();
Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block1));
byte[] contractAddress = tx.getContractAddress().getBytes();
Transaction tx2 = getContractTransactionWithInvoke(acc1, contractAddress);
List<Transaction> tx2s = new ArrayList<>();
tx2s.add(tx2);
Block block2 = new BlockBuilder(world).parent(block1).transactions(tx2s).build();
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block2));
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), receiptStore, null, null, 10, 100);
Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool, receiptStore);
web3.personal_newAccountWithSeed("default");
web3.personal_newAccountWithSeed("notDefault");
return web3;
}
use of co.rsk.core.bc.TransactionPoolImpl in project rskj by rsksmart.
the class Web3ImplLogsTest method getWeb3WithContractCall.
private Web3Impl getWeb3WithContractCall(World world) {
Account acc1 = new AccountBuilder(world).name("notDefault").balance(Coin.valueOf(10000000)).build();
// acc1 Account created address should be 661b05ca9eb621164906671efd2731ce0d7dd8b4
Block genesis = world.getBlockByName("g00");
Transaction tx;
tx = getContractTransaction(acc1);
List<Transaction> txs = new ArrayList<>();
txs.add(tx);
BlockChainImpl blockChain = world.getBlockChain();
Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block1));
byte[] contractAddress = tx.getContractAddress().getBytes();
// Now create a transaction that invokes Increment()
Transaction tx2 = getContractTransactionWithInvoke(acc1, contractAddress);
List<Transaction> tx2s = new ArrayList<>();
tx2s.add(tx2);
Block block2 = new BlockBuilder(world).parent(block1).transactions(tx2s).build();
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block2));
Transaction tx3 = getContractTransactionWithCall(acc1, contractAddress);
List<Transaction> tx3s = new ArrayList<>();
tx3s.add(tx3);
Block block3 = new BlockBuilder(world).parent(block2).transactions(tx3s).build();
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(block3));
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool);
web3.personal_newAccountWithSeed("default");
web3.personal_newAccountWithSeed("notDefault");
return web3;
}
use of co.rsk.core.bc.TransactionPoolImpl in project rskj by rsksmart.
the class ImportLightTest method createBlockchain.
public static BlockChainImpl createBlockchain(Genesis genesis) {
RskSystemProperties config = new RskSystemProperties();
config.setBlockchainConfig(new GenesisConfig(new GenesisConfig.GenesisConstants() {
@Override
public BlockDifficulty getMinimumDifficulty() {
return new BlockDifficulty(BigInteger.ONE);
}
}));
IndexedBlockStore blockStore = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
Repository repository = new RepositoryImpl(config, new TrieStoreImpl(new HashMapDB()));
EthereumListenerAdapter listener = new EthereumListenerAdapter();
KeyValueDataSource ds = new HashMapDB();
ds.init();
ReceiptStore receiptStore = new ReceiptStoreImpl(ds);
BlockChainImpl blockchain = new BlockChainImpl(config, repository, blockStore, receiptStore, null, listener, new AdminInfo(), new DummyBlockValidator());
blockchain.setNoValidation(true);
TransactionPoolImpl transactionPool = new TransactionPoolImpl(config, repository, null, receiptStore, null, listener, 10, 100);
blockchain.setTransactionPool(transactionPool);
Repository track = repository.startTracking();
for (RskAddress addr : genesis.getPremine().keySet()) {
track.createAccount(addr);
track.addBalance(addr, genesis.getPremine().get(addr).getAccountState().getBalance());
}
track.commit();
genesis.setStateRoot(repository.getRoot());
genesis.flushRLP();
blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
blockchain.setBestBlock(genesis);
blockchain.setTotalDifficulty(genesis.getCumulativeDifficulty());
return blockchain;
}
use of co.rsk.core.bc.TransactionPoolImpl in project rskj by rsksmart.
the class Web3ImplTest method createWeb3.
private Web3Impl createWeb3(Ethereum eth, World world, ReceiptStore receiptStore) {
BlockChainImpl blockChain = world.getBlockChain();
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
return createWeb3(eth, world, transactionPool, receiptStore);
}
use of co.rsk.core.bc.TransactionPoolImpl in project rskj by rsksmart.
the class Web3ImplTest method createWeb3.
private Web3Impl createWeb3(World world, BlockProcessor blockProcessor, ReceiptStore receiptStore) {
BlockChainImpl blockChain = world.getBlockChain();
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
return createWeb3(Web3Mocks.getMockEthereum(), blockChain, transactionPool, blockChain.getBlockStore(), blockProcessor, new SimpleConfigCapabilities(), receiptStore);
}
Aggregations