Search in sources :

Example 11 with TransactionResultDTO

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);
}
Also used : TransactionPoolImpl(co.rsk.core.bc.TransactionPoolImpl) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) TransactionResultDTO(org.ethereum.rpc.dto.TransactionResultDTO) AccountBuilder(co.rsk.test.builders.AccountBuilder) World(co.rsk.test.World) Test(org.junit.Test)

Aggregations

TransactionResultDTO (org.ethereum.rpc.dto.TransactionResultDTO)11 World (co.rsk.test.World)7 Test (org.junit.Test)7 BlockBuilder (co.rsk.test.builders.BlockBuilder)6 AccountBuilder (co.rsk.test.builders.AccountBuilder)5 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)5 Coin (co.rsk.core.Coin)1 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)1 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)1 Keccak256 (co.rsk.crypto.Keccak256)1 TransactionInfo (org.ethereum.db.TransactionInfo)1