Search in sources :

Example 41 with TransactionBuilder

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

the class VMSpecificOpcodesPerformanceTest method createTransaction.

private static Transaction createTransaction(int number) {
    AccountBuilder acbuilder = new AccountBuilder();
    acbuilder.name("sender" + number);
    Account sender = acbuilder.build();
    acbuilder.name("receiver" + number);
    Account receiver = acbuilder.build();
    TransactionBuilder txbuilder = new TransactionBuilder();
    return txbuilder.sender(sender).receiver(receiver).value(BigInteger.valueOf(number * 1000 + 1000)).build();
}
Also used : Account(org.ethereum.core.Account) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 42 with TransactionBuilder

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

the class MessageTest method createTransaction.

private static Transaction createTransaction(int number) {
    AccountBuilder acbuilder = new AccountBuilder();
    acbuilder.name("sender" + number);
    Account sender = acbuilder.build();
    acbuilder.name("receiver" + number);
    Account receiver = acbuilder.build();
    TransactionBuilder txbuilder = new TransactionBuilder();
    return txbuilder.sender(sender).receiver(receiver).value(BigInteger.valueOf(number * 1000 + 1000)).build();
}
Also used : TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 43 with TransactionBuilder

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

the class TransactionBuilderTest method buildTransaction.

@Test
public void buildTransaction() {
    Account sender = new AccountBuilder().name("sender").build();
    Account receiver = new AccountBuilder().name("receiver").build();
    Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.TEN).nonce(2).build();
    Assert.assertNotNull(tx);
    Assert.assertArrayEquals(sender.getAddress().getBytes(), tx.getSender().getBytes());
    Assert.assertArrayEquals(receiver.getAddress().getBytes(), tx.getReceiveAddress().getBytes());
    Assert.assertEquals(BigInteger.TEN, tx.getValue().asBigInteger());
    Assert.assertEquals(BigInteger.ONE, tx.getGasPrice().asBigInteger());
    Assert.assertEquals(BigInteger.valueOf(2), new BigInteger(1, tx.getNonce()));
    Assert.assertEquals(BigInteger.valueOf(21000), new BigInteger(1, tx.getGasLimit()));
    Assert.assertNotNull(tx.getData());
    Assert.assertEquals(0, tx.getData().length);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) BigInteger(java.math.BigInteger) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 44 with TransactionBuilder

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

the class Web3ImplLogsTest method getWeb3WithContractCreationWithoutEvents.

private Web3Impl getWeb3WithContractCreationWithoutEvents() {
    World world = new World();
    Account acc1 = new AccountBuilder(world).name("notDefault").balance(Coin.valueOf(10000000)).build();
    Block genesis = world.getBlockByName("g00");
    /* contract compiled in data attribute of tx
        contract greeter {

            address owner;
            modifier onlyOwner { if (msg.sender != owner) throw; _ ; }

            function greeter() public {
                owner = msg.sender;
            }
            function greet(string param) onlyOwner constant returns (string) {
                return param;
            }
        } */
    Transaction tx = new TransactionBuilder().sender(acc1).gasLimit(BigInteger.valueOf(100000)).gasPrice(BigInteger.ONE).data(compiledGreeter).build();
    List<Transaction> txs = new ArrayList<>();
    txs.add(tx);
    BlockChainImpl blockChain = world.getBlockChain();
    Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
    blockChain.tryToConnect(block1);
    TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
    Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool);
    web3.personal_newAccountWithSeed("notDefault");
    return web3;
}
Also used : ArrayList(java.util.ArrayList) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) World(co.rsk.test.World) TransactionPoolImpl(co.rsk.core.bc.TransactionPoolImpl) AccountBuilder(co.rsk.test.builders.AccountBuilder) BlockBuilder(co.rsk.test.builders.BlockBuilder)

Example 45 with TransactionBuilder

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

the class ContractRunner method runContract.

private ProgramResult runContract(byte[] contractAddress, byte[] encodedCall, BigInteger value) {
    BigInteger nonceExecute = repository.getNonce(sender.getAddress());
    Transaction transaction = new TransactionBuilder().gasLimit(BigInteger.valueOf(10_000_000)).sender(sender).receiverAddress(contractAddress).data(encodedCall).nonce(nonceExecute.longValue()).value(value).build();
    return executeTransaction(transaction).getResult();
}
Also used : BigInteger(java.math.BigInteger) TransactionBuilder(co.rsk.test.builders.TransactionBuilder)

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