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();
}
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();
}
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);
}
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;
}
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();
}
Aggregations