use of org.ethereum.rpc.dto.TransactionResultDTO 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);
}
Aggregations