use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.
the class AccountBuilderTest method createAccountWithBalanceAndCode.
@Test
public void createAccountWithBalanceAndCode() {
World world = new World();
byte[] code = new byte[] { 0x01, 0x02, 0x03 };
Coin balance = Coin.valueOf(10);
Account account = new AccountBuilder(world).name("acc1").balance(balance).code(code).build();
Assert.assertNotNull(account);
Assert.assertTrue(account.getEcKey().hasPrivKey());
Assert.assertEquals(balance, world.getRepository().getBalance(account.getAddress()));
Assert.assertArrayEquals(code, world.getRepository().getCode(account.getAddress()));
}
use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.
the class CallContractTest method callContractReturningOne.
@Test
public void callContractReturningOne() {
World world = new World();
byte[] code = new byte[] { 0x60, 0x01, 0x60, 0x00, 0x52, 0x60, 0x20, 0x60, 0x00, (byte) 0xf3 };
Account account = new AccountBuilder(world).name("acc1").code(code).build();
ProgramResult result = callContract(world, account.getAddress(), new byte[0]);
Assert.assertNotNull(result);
byte[] value = result.getHReturn();
Assert.assertNotNull(value);
Assert.assertEquals(32, value.length);
Assert.assertEquals(BigInteger.ONE, new BigInteger(1, value));
}
use of co.rsk.test.builders.AccountBuilder 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;
}
use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.
the class WriterMessageRecorderTest method createEthMessage.
public static Message createEthMessage() {
Account acc1 = new AccountBuilder().name("acc1").build();
Account acc2 = new AccountBuilder().name("acc2").build();
Transaction tx = new co.rsk.test.builders.TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
return new TransactionsMessage(config, tx);
}
use of co.rsk.test.builders.AccountBuilder 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();
}
Aggregations