Search in sources :

Example 11 with TransactionBuilder

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

the class TransactionFactoryHelper method createSampleTransactionWithData.

public static Transaction createSampleTransactionWithData(int from, int nonce, String data) {
    Account sender = createAccount(from);
    Transaction tx = new TransactionBuilder().sender(sender).receiverAddress(new byte[0]).nonce(nonce).data(data).gasLimit(BigInteger.valueOf(1000000)).build();
    return tx;
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder)

Example 12 with TransactionBuilder

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

the class ImmutableTransactionTest method createImmutableTransaction.

private static Transaction createImmutableTransaction() {
    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).immutable().build();
    return tx;
}
Also used : Account(org.ethereum.core.Account) ImmutableTransaction(org.ethereum.core.ImmutableTransaction) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 13 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 14 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 15 with TransactionBuilder

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

the class TxPoolModuleImplTest method createSampleTransaction.

private Transaction createSampleTransaction(int from, int to, long value, int nonce) {
    Account sender = getAccount(from);
    Account receiver = getAccount(to);
    Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).nonce(nonce).value(BigInteger.valueOf(value)).build();
    return tx;
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder)

Aggregations

TransactionBuilder (co.rsk.test.builders.TransactionBuilder)29 AccountBuilder (co.rsk.test.builders.AccountBuilder)24 Test (org.junit.Test)17 World (co.rsk.test.World)15 BlockBuilder (co.rsk.test.builders.BlockBuilder)13 Account (org.ethereum.core.Account)10 Transaction (org.ethereum.core.Transaction)9 TransactionResultDTO (org.ethereum.rpc.dto.TransactionResultDTO)5 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)3 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)3 BigInteger (java.math.BigInteger)3 HashMapDB (org.ethereum.datasource.HashMapDB)3 ReceiptStore (org.ethereum.db.ReceiptStore)3 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)3 TransactionReceiptDTO (org.ethereum.rpc.dto.TransactionReceiptDTO)2 TestContract (co.rsk.util.TestContract)1 ArrayList (java.util.ArrayList)1 ImmutableTransaction (org.ethereum.core.ImmutableTransaction)1