use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TransactionResultDTOTest method remascAddressSerialization.
@Test
public void remascAddressSerialization() {
Block b = mock(Block.class);
Integer index = 42;
Transaction tx = mock(Transaction.class);
when(tx.getHash()).thenReturn(new Keccak256(TestUtils.randomBytes(32)));
when(tx.getSender()).thenReturn(RemascTransaction.REMASC_ADDRESS);
when(tx.getReceiveAddress()).thenReturn(TestUtils.randomAddress());
when(tx.getGasPrice()).thenReturn(Coin.valueOf(42));
when(tx.getValue()).thenReturn(Coin.ZERO);
when(tx.getData()).thenReturn(TestUtils.randomBytes(2));
TransactionResultDTO dto = new TransactionResultDTO(b, index, tx);
assertThat(dto.from, is("0x0000000000000000000000000000000000000000"));
}
use of org.ethereum.core.Transaction 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;
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class DslFilesTest method runCreate01Resource.
@Test
public void runCreate01Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/create01.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Transaction transaction = world.getTransactionByName("tx01");
Assert.assertNotNull(transaction);
TransactionInfo txinfo = world.getBlockChain().getTransactionInfo(transaction.getHash().getBytes());
Assert.assertNotNull(txinfo);
BigInteger gasUsed = BigIntegers.fromUnsignedByteArray(txinfo.getReceipt().getGasUsed());
Assert.assertNotEquals(BigInteger.ZERO, gasUsed);
// According to TestRPC and geth, the gas used is 0x010c2d
Assert.assertEquals(BigIntegers.fromUnsignedByteArray(Hex.decode("010c2d")), gasUsed);
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class WorldDslProcessorTest method processTransactionBuildCommand.
@Test
public void processTransactionBuildCommand() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1\naccount_new acc2\ntransaction_build tx01\nsender acc1\nreceiver acc2\nvalue 1000\nbuild");
processor.processCommands(parser);
Account acc1 = world.getAccountByName("acc1");
Account acc2 = world.getAccountByName("acc2");
Assert.assertNotNull(acc1);
Assert.assertNotNull(acc2);
Transaction tx01 = world.getTransactionByName("tx01");
Assert.assertNotNull(tx01);
Assert.assertArrayEquals(acc1.getAddress().getBytes(), tx01.getSender().getBytes());
Assert.assertArrayEquals(acc2.getAddress().getBytes(), tx01.getReceiveAddress().getBytes());
Assert.assertEquals(new BigInteger("1000"), tx01.getValue().asBigInteger());
Assert.assertNotNull(tx01.getData());
Assert.assertEquals(0, tx01.getData().length);
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class WorldDslProcessorTest method processTransactionWithGasAndGasPriceBuildCommand.
@Test
public void processTransactionWithGasAndGasPriceBuildCommand() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1\naccount_new acc2\ntransaction_build tx01\nsender acc1\nreceiver acc2\nvalue 1000\ngas 1200000\ngasPrice 2\nbuild");
processor.processCommands(parser);
Account acc1 = world.getAccountByName("acc1");
Account acc2 = world.getAccountByName("acc2");
Assert.assertNotNull(acc1);
Assert.assertNotNull(acc2);
Transaction tx01 = world.getTransactionByName("tx01");
Assert.assertNotNull(tx01);
Assert.assertArrayEquals(acc1.getAddress().getBytes(), tx01.getSender().getBytes());
Assert.assertArrayEquals(acc2.getAddress().getBytes(), tx01.getReceiveAddress().getBytes());
Assert.assertEquals(new BigInteger("1000"), tx01.getValue().asBigInteger());
Assert.assertNotNull(tx01.getData());
Assert.assertEquals(0, tx01.getData().length);
Assert.assertEquals(new BigInteger("2"), tx01.getGasPrice().asBigInteger());
Assert.assertEquals(new BigInteger("1200000"), tx01.getGasLimitAsInteger());
}
Aggregations