Search in sources :

Example 46 with TransactionBuilder

use of co.rsk.test.builders.TransactionBuilder in project rskj by rsksmart.

the class RskTestFactory method executeRawContract.

public ProgramResult executeRawContract(byte[] bytecode, byte[] encodedCall, BigInteger value) {
    Account sender = new AccountBuilder(getBlockchain()).name("sender").balance(Coin.valueOf(10000000L)).build();
    BigInteger nonceCreate = getRepository().getNonce(sender.getAddress());
    Transaction creationTx = new TransactionBuilder().gasLimit(BigInteger.valueOf(3000000)).sender(sender).data(bytecode).nonce(nonceCreate.longValue()).build();
    executeTransaction(creationTx);
    BigInteger nonceExecute = getRepository().getNonce(sender.getAddress());
    Transaction transaction = new TransactionBuilder().gasLimit(BigInteger.valueOf(3000000)).sender(sender).receiverAddress(creationTx.getContractAddress().getBytes()).data(encodedCall).nonce(nonceExecute.longValue()).value(value).build();
    return executeTransaction(transaction).getResult();
}
Also used : BigInteger(java.math.BigInteger) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Aggregations

TransactionBuilder (co.rsk.test.builders.TransactionBuilder)46 AccountBuilder (co.rsk.test.builders.AccountBuilder)41 Test (org.junit.Test)25 World (co.rsk.test.World)24 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 Account (org.ethereum.core.Account)17 BlockBuilder (co.rsk.test.builders.BlockBuilder)13 Transaction (org.ethereum.core.Transaction)12 ReceiptStore (org.ethereum.db.ReceiptStore)9 HashMapDB (org.ethereum.datasource.HashMapDB)6 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)6 BigInteger (java.math.BigInteger)5 ArrayList (java.util.ArrayList)5 TransactionResultDTO (org.ethereum.rpc.dto.TransactionResultDTO)5 BlockResultDTO (org.ethereum.rpc.dto.BlockResultDTO)4 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)3 Keccak256 (co.rsk.crypto.Keccak256)3 Trie (co.rsk.trie.Trie)3 Block (org.ethereum.core.Block)3 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)2