use of co.rsk.core.bc.BlockChainImpl in project rskj by rsksmart.
the class Web3ImplTest method getPendingTransactionByHash.
@Test
public void getPendingTransactionByHash() throws Exception {
World world = new World();
BlockChainImpl blockChain = world.getBlockChain();
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
transactionPool.processBest(blockChain.getBestBlock());
Web3Impl web3 = createWeb3(world, transactionPool, null);
Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build();
Account acc2 = new AccountBuilder().name("acc2").build();
Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
transactionPool.addTransaction(tx);
String hashString = tx.getHash().toHexString();
TransactionResultDTO tr = web3.eth_getTransactionByHash(hashString);
Assert.assertNotNull(tr);
org.junit.Assert.assertEquals("0x" + hashString, tr.hash);
org.junit.Assert.assertEquals("0", tr.nonce);
org.junit.Assert.assertEquals(null, tr.blockHash);
org.junit.Assert.assertEquals(null, tr.transactionIndex);
org.junit.Assert.assertEquals("0x00", tr.input);
org.junit.Assert.assertEquals("0x" + Hex.toHexString(tx.getReceiveAddress().getBytes()), tr.to);
}
use of co.rsk.core.bc.BlockChainImpl in project rskj by rsksmart.
the class RskTestFactory method getBlockchain.
public BlockChainImpl getBlockchain() {
if (blockchain == null) {
blockchain = new BlockChainImpl(config, getRepository(), getBlockStore(), getReceiptStore(), // circular dependency
null, null, null, new DummyBlockValidator());
TransactionPool transactionPool = getTransactionPool();
blockchain.setTransactionPool(transactionPool);
}
return blockchain;
}
use of co.rsk.core.bc.BlockChainImpl in project rskj by rsksmart.
the class WorldDslProcessor method processBlockConnectCommand.
private void processBlockConnectCommand(DslCommand cmd) {
BlockChainImpl blockChain = world.getBlockChain();
int nblocks = cmd.getArity();
for (int k = 0; k < nblocks; k++) {
String name = cmd.getArgument(k);
Block block = world.getBlockByName(name);
BlockExecutor executor = world.getBlockExecutor();
executor.executeAndFill(block, blockChain.getBestBlock());
block.seal();
latestImportResult = blockChain.tryToConnect(block);
}
}
Aggregations