Search in sources :

Example 6 with TransactionsMessage

use of org.ethereum.net.eth.message.TransactionsMessage 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);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionsMessage(org.ethereum.net.eth.message.TransactionsMessage) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 7 with TransactionsMessage

use of org.ethereum.net.eth.message.TransactionsMessage in project rskj by rsksmart.

the class TransactionsMessageTest method test_2.

@Ignore
@Test
public /* Transactions message 2 */
void test_2() {
    String txsPacketRaw = "f9025012f89d8080940000000000000000000000000000000000000000860918" + "4e72a000822710b3606956330c0d630000003359366000530a0d630000003359" + "602060005301356000533557604060005301600054630000000c588433606957" + "1ca07f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402" + "c3c4a06d254e662bf7450dd8d835160cbb053463fed0b53f2cdd7f3ea8731919" + "c8e8ccf901050180940000000000000000000000000000000000000000860918" + "4e72a000822710b85336630000002e59606956330c0d63000000155933ff3356" + "0d63000000275960003356576000335700630000005358600035560d63000000" + "3a590033560d63000000485960003356573360003557600035335700b84a7f4e" + "616d655265670000000000000000000000000000000000000000000000000030" + "57307f4e616d6552656700000000000000000000000000000000000000000000" + "00000057336069571ba04af15a0ec494aeac5b243c8a2690833faa74c0f73db1" + "f439d521c49c381513e9a05802e64939be5a1f9d4d614038fbd5479538c48795" + "614ef9c551477ecbdb49d2f8a6028094ccdeac59d35627b7de09332e819d5159" + "e7bb72508609184e72a000822710b84000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000002d0aceee" + "7e5ab874e22ccf8d1a649f59106d74e81ba0d05887574456c6de8f7a0d172342" + "c2cbdd4cf7afe15d9dbb8b75b748ba6791c9a01e87172a861f6c37b5a9e3a5d0" + "d7393152a7fbe41530e5bb8ac8f35433e5931b";
    byte[] payload = Hex.decode(txsPacketRaw);
    TransactionsMessage transactionsMessage = new TransactionsMessage(config, payload);
    System.out.println(transactionsMessage);
    assertEquals(EthMessageCodes.TRANSACTIONS, transactionsMessage.getCommand());
    assertEquals(3, transactionsMessage.getTransactions().size());
    Iterator<Transaction> txIter = transactionsMessage.getTransactions().iterator();
    Transaction tx1 = txIter.next();
    // skip one
    txIter.next();
    Transaction tx3 = txIter.next();
    assertEquals("1b9d9456293cbcbc2f28a0fdc67028128ea571b033fb0e21d0ee00bcd6167e5d", tx3.getHash().toHexString());
    assertEquals("00", Hex.toHexString(tx3.getNonce()));
    assertEquals("2710", Hex.toHexString(tx3.getValue().getBytes()));
    assertEquals("09184e72a000", Hex.toHexString(tx3.getReceiveAddress().getBytes()));
    assertNull(tx3.getGasPrice());
    assertEquals("0000000000000000000000000000000000000000", Hex.toHexString(tx3.getGasLimit()));
    assertEquals("606956330c0d630000003359366000530a0d630000003359602060005301356000533557604060005301600054630000000c58", Hex.toHexString(tx3.getData()));
    assertEquals("33", Hex.toHexString(new byte[] { tx3.getSignature().v }));
    assertEquals("1c", Hex.toHexString(tx3.getSignature().r.toByteArray()));
    assertEquals("7f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402c3c4", Hex.toHexString(tx3.getSignature().s.toByteArray()));
    // Transaction #2
    assertEquals("dde9543921850f41ca88e5401322cd7651c78a1e4deebd5ee385af8ac343f0ad", tx1.getHash().toHexString());
    assertEquals("02", Hex.toHexString(tx1.getNonce()));
    assertEquals("2710", Hex.toHexString(tx1.getValue().getBytes()));
    assertEquals("09184e72a000", Hex.toHexString(tx1.getReceiveAddress().getBytes()));
    assertNull(tx1.getGasPrice());
    assertEquals("ccdeac59d35627b7de09332e819d5159e7bb7250", Hex.toHexString(tx1.getGasLimit()));
    assertEquals("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d0aceee7e5ab874e22ccf8d1a649f59106d74e8", Hex.toHexString(tx1.getData()));
    assertEquals("1b", Hex.toHexString(new byte[] { tx1.getSignature().v }));
    assertEquals("00d05887574456c6de8f7a0d172342c2cbdd4cf7afe15d9dbb8b75b748ba6791c9", Hex.toHexString(tx1.getSignature().r.toByteArray()));
    assertEquals("1e87172a861f6c37b5a9e3a5d0d7393152a7fbe41530e5bb8ac8f35433e5931b", Hex.toHexString(tx1.getSignature().s.toByteArray()));
}
Also used : Transaction(org.ethereum.core.Transaction) TransactionsMessage(org.ethereum.net.eth.message.TransactionsMessage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TransactionsMessage (org.ethereum.net.eth.message.TransactionsMessage)7 Transaction (org.ethereum.core.Transaction)4 Test (org.junit.Test)4 Ignore (org.junit.Ignore)2 AccountBuilder (co.rsk.test.builders.AccountBuilder)1 BigInteger (java.math.BigInteger)1 Account (org.ethereum.core.Account)1 ECKey (org.ethereum.crypto.ECKey)1