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();
}
use of co.rsk.test.builders.TransactionBuilder in project rskj by rsksmart.
the class TransactionFactoryHelper method createSampleTransaction.
public static Transaction createSampleTransaction(long nonce) {
Account sender = new AccountBuilder().name("sender").build();
Account receiver = new AccountBuilder().name("receiver").build();
Transaction tx = new TransactionBuilder().nonce(nonce).sender(sender).receiver(receiver).value(BigInteger.TEN).build();
return tx;
}
use of co.rsk.test.builders.TransactionBuilder in project rskj by rsksmart.
the class TransactionFactoryHelper method createSampleTransaction.
public static Transaction createSampleTransaction(int from, int to, long value, int nonce) {
Account sender = createAccount(from);
Account receiver = createAccount(to);
Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).nonce(nonce).value(BigInteger.valueOf(value)).build();
return tx;
}
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);
}
Aggregations