Initial separation of message tests

This commit is contained in:
nicksavers 2014-09-22 09:02:34 +02:00
parent 522e23679a
commit fd3014a1ae
10 changed files with 507 additions and 499 deletions

View File

@ -24,10 +24,8 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import static org.ethereum.net.Command.*;
import static org.ethereum.net.message.StaticMessages.*;
/**
* www.ethereumJ.com
* @author: Roman Mandeleil

View File

@ -20,36 +20,29 @@ import java.math.BigInteger;
*/
public class HelloMessage extends Message {
private byte protocolVersion;
private byte networkId;
/** The implemented version of the P2P protocol. */
private byte p2pVersion;
/** The underlying client. A user-readable string. */
private String clientId;
/** A peer-network capability code, readable ASCII and 3 letters.
* Currently only "eth" and "shh" are known. */
private byte capabilities;
private short peerPort;
/** The port on which the peer is listening for an incoming connection */
private short listenPort;
/** The identity and public key of the peer */
private byte[] peerId;
/** Total difficulty of the best chain as found in block header. */
private byte[] totalDifficulty;
/** The hash of the best (i.e. highest TD) known block. */
private byte[] bestHash;
/** The hash of the Genesis block */
private byte[] genesisHash;
public HelloMessage(RLPList rawData) {
super(rawData);
}
public HelloMessage(byte protocolVersion, byte networkId, String clientId,
byte capabilities, short peerPort, byte[] peerId, byte[] totalDifficulty,
byte[] bestHash, byte[] genesisHash) {
this.protocolVersion = protocolVersion;
this.networkId = networkId;
public HelloMessage(byte p2pVersion, String clientId,
byte capabilities, short listenPort, byte[] peerId) {
this.p2pVersion = p2pVersion;
this.clientId = clientId;
this.capabilities = capabilities;
this.peerPort = peerPort;
this.listenPort = listenPort;
this.peerId = peerId;
this.totalDifficulty = totalDifficulty;
this.bestHash = bestHash;
this.genesisHash = genesisHash;
this.parsed = true;
}
@ -60,30 +53,20 @@ public class HelloMessage extends Message {
// the message does no distinguish between the 0 and null so here I check command code for null
// TODO: find out if it can be 00
if (((RLPItem)paramsList.get(0)).getRLPData() != null) {
if (((RLPItem) paramsList.get(0)).getRLPData() != null)
throw new Error("HelloMessage: parsing for mal data");
}
this.protocolVersion = ((RLPItem) paramsList.get(1)).getRLPData()[0];
this.p2pVersion = ((RLPItem) paramsList.get(1)).getRLPData()[0];
byte[] networkIdBytes = ((RLPItem) paramsList.get(2)).getRLPData();
this.networkId = networkIdBytes == null ? 0 : networkIdBytes[0];
byte[] clientIdBytes = ((RLPItem) paramsList.get(3)).getRLPData();
byte[] clientIdBytes = ((RLPItem) paramsList.get(2)).getRLPData();
this.clientId = new String(clientIdBytes != null ? clientIdBytes : EMPTY_BYTE_ARRAY);
this.capabilities = ((RLPItem) paramsList.get(4)).getRLPData()[0];
this.capabilities = ((RLPItem) paramsList.get(3)).getRLPData()[0];
byte[] peerPortBytes = ((RLPItem) paramsList.get(5)).getRLPData();
this.peerPort = new BigInteger(peerPortBytes).shortValue();
byte[] peerPortBytes = ((RLPItem) paramsList.get(4)).getRLPData();
this.listenPort = new BigInteger(peerPortBytes).shortValue();
this.peerId = ((RLPItem) paramsList.get(6)).getRLPData();
this.totalDifficulty = ((RLPItem) paramsList.get(7)).getRLPData();
this.bestHash = ((RLPItem) paramsList.get(8)).getRLPData();
this.genesisHash = ((RLPItem) paramsList.get(9)).getRLPData();
this.peerId = ((RLPItem) paramsList.get(5)).getRLPData();
this.parsed = true;
// TODO: what to do when mal data ?
@ -92,19 +75,14 @@ public class HelloMessage extends Message {
public byte[] getPayload() {
byte[] command = RLP.encodeByte(HELLO.asByte());
byte[] protocolVersion = RLP.encodeByte(this.protocolVersion);
byte[] networkId = RLP.encodeByte(this.networkId);
byte[] protocolVersion = RLP.encodeByte(this.p2pVersion);
byte[] clientId = RLP.encodeString(this.clientId);
byte[] capabilities = RLP.encodeByte(this.capabilities);
byte[] peerPort = RLP.encodeShort(this.peerPort);
byte[] peerPort = RLP.encodeShort(this.listenPort);
byte[] peerId = RLP.encodeElement(this.peerId);
byte[] totalDifficulty = RLP.encodeElement(this.totalDifficulty);
byte[] bestHash = RLP.encodeElement(this.bestHash);
byte[] genesisHash = RLP.encodeElement(this.genesisHash);
byte[] data = RLP.encodeList(command, protocolVersion, networkId,
clientId, capabilities, peerPort, peerId, totalDifficulty,
bestHash, genesisHash);
byte[] data = RLP.encodeList(command, protocolVersion,
clientId, capabilities, peerPort, peerId);
return data;
}
@ -114,14 +92,9 @@ public class HelloMessage extends Message {
return HELLO.asByte();
}
public byte getProtocolVersion() {
public byte getP2PVersion() {
if (!parsed) parseRLP();
return protocolVersion;
}
public byte getNetworkId() {
if (!parsed) parseRLP();
return networkId;
return p2pVersion;
}
public String getClientId() {
@ -134,9 +107,9 @@ public class HelloMessage extends Message {
return capabilities;
}
public short getPeerPort() {
public short getListenPort() {
if (!parsed) parseRLP();
return peerPort;
return listenPort;
}
public byte[] getPeerId() {
@ -144,21 +117,6 @@ public class HelloMessage extends Message {
return peerId;
}
public byte[] getTotalDifficulty() {
if (!parsed) parseRLP();
return totalDifficulty;
}
public byte[] getBestHash() {
if (!parsed) parseRLP();
return bestHash;
}
public byte[] getGenesisHash() {
if (!parsed) parseRLP();
return genesisHash;
}
@Override
public String getMessageName() {
return "HelloMessage";
@ -172,15 +130,11 @@ public class HelloMessage extends Message {
public String toString() {
if (!parsed) parseRLP();
return "Hello Message [ command=" + HELLO.asByte() + " " +
" protocolVersion=" + this.protocolVersion + " " +
" networkId=" + this.networkId + " " +
" p2pVersion=" + this.p2pVersion + " " +
" clientId=" + this.clientId + " " +
" capabilities=" + this.capabilities + " " +
" peerPort=" + this.peerPort + " " +
" peerPort=" + this.listenPort + " " +
" peerId=" + Hex.toHexString(this.peerId) + " " +
" totalDifficulty=" + Hex.toHexString(this.totalDifficulty) + " " +
" bestHash=" + Hex.toHexString(this.bestHash) + " " +
" genesisHash=" + Hex.toHexString(this.genesisHash) + " " +
"]";
}
}

View File

@ -1,10 +1,8 @@
package org.ethereum.net.message;
import org.ethereum.config.SystemProperties;
import org.ethereum.core.Block;
import org.ethereum.core.Genesis;
import org.ethereum.crypto.HashUtil;
import org.ethereum.manager.WorldManager;
import org.spongycastle.util.encoders.Hex;
/**
@ -14,9 +12,10 @@ import org.spongycastle.util.encoders.Hex;
*/
public class StaticMessages {
public final static PingMessage PING_MESSAGE = new PingMessage();
public final static PongMessage PONG_MESSAGE = new PongMessage();
public final static GetPeersMessage GET_PEERS_MESSAGE = new GetPeersMessage();
public final static PingMessage PING_MESSAGE = new PingMessage();
public final static PongMessage PONG_MESSAGE = new PongMessage();
public final static HelloMessage HELLO_MESSAGE = generateHelloMessage();
public final static GetPeersMessage GET_PEERS_MESSAGE = new GetPeersMessage();
public final static GetTransactionsMessage GET_TRANSACTIONS_MESSAGE = new GetTransactionsMessage();
public static final byte[] PING_PACKET = Hex.decode("2240089100000002C102");
@ -28,12 +27,8 @@ public class StaticMessages {
public static final byte[] SYNC_TOKEN = Hex.decode("22400891");
public static final byte[] GENESIS_HASH = Genesis.getInstance().getHash();
static {
HELLO_MESSAGE = generateHelloMessage();
}
public static HelloMessage HELLO_MESSAGE;
public static HelloMessage generateHelloMessage() {
private static HelloMessage generateHelloMessage() {
byte[] peerIdBytes = HashUtil.randomPeerId();
String version = SystemProperties.CONFIG.projectVersion();
@ -46,13 +41,8 @@ public class StaticMessages {
String phrase = SystemProperties.CONFIG.helloPhrase();
String helloAnnouncement = String.format("Ethereum(J)/v%s/%s/%s/Java", version, phrase, system);
Block lastBlock = WorldManager.getInstance().getBlockchain().getLastBlock();
byte[] totalDifficulty = lastBlock.getDifficulty();
byte[] bestHash = lastBlock.getHash();
return new HelloMessage((byte) 0x21, (byte) 0x00,
helloAnnouncement, Byte.parseByte("00000111", 2),
(short) 30303, peerIdBytes, totalDifficulty, bestHash, GENESIS_HASH);
return new HelloMessage((byte) 0x21, helloAnnouncement,
Byte.parseByte("00000111", 2), (short) 30303, peerIdBytes);
}
}

View File

@ -51,7 +51,7 @@ public class EthereumPeerTasterHandler extends ChannelInboundHandlerAdapter {
// Here we send the hello message with random id each time
// to not interrupt active peer
HelloMessage helloMessage = StaticMessages.generateHelloMessage();
HelloMessage helloMessage = StaticMessages.HELLO_MESSAGE;
byte[] helloLength =ByteUtil.calcPacketLength(helloMessage.getPayload());

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
package org.ethereum.net;
import static org.junit.Assert.assertEquals;
import org.ethereum.net.message.DisconnectMessage;
import org.ethereum.net.message.ReasonCode;
import org.ethereum.util.RLP;
import org.ethereum.util.RLPList;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
public class DisconnectMessageTest {
/* DISCONNECT_MESSAGE */
@Test /* DisconnectMessage 1 */
public void test_3() {
String disconnectMessageRaw = "C20100";
byte[] payload = Hex.decode(disconnectMessageRaw);
RLPList rlpList = RLP.decode2(payload);
DisconnectMessage disconnectMessage = new DisconnectMessage(rlpList);
System.out.println(disconnectMessage);
assertEquals(disconnectMessage.getReason(), ReasonCode.REQUESTED);
}
@Test /* DisconnectMessage 2 */
public void test_4() {
String disconnectMessageRaw = "C20101";
byte[] payload = Hex.decode(disconnectMessageRaw);
RLPList rlpList = RLP.decode2(payload);
DisconnectMessage disconnectMessage = new DisconnectMessage(rlpList);
System.out.println(disconnectMessage);
assertEquals(disconnectMessage.getReason(), ReasonCode.TCP_ERROR);
}
}

View File

@ -0,0 +1,62 @@
package org.ethereum.net;
import static org.junit.Assert.assertEquals;
import org.ethereum.net.message.HelloMessage;
import org.ethereum.util.RLP;
import org.ethereum.util.RLPList;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
public class HelloMessageTest {
/* HELLO_MESSAGE */
@Test /* HelloMessage 1 */
public void test_1() {
String helloMessageRaw = "F8 77 80 0C 80 AD 45 74 " +
"68 65 72 65 75 6D 28 2B 2B 29 2F 5A 65 72 6F 47 " +
"6F 78 2F 76 30 2E 35 2E 31 2F 6E 63 75 72 73 65 " +
"73 2F 4C 69 6E 75 78 2F 67 2B 2B 07 82 76 5F B8 " +
"40 D8 83 3B 83 56 0E 0B 12 17 0E 91 69 DC 43 78 " +
"42 23 A5 98 42 DE 23 59 E6 D0 3D B3 4C 30 A9 66 " +
"C2 DE 3B 4B 25 52 FB 0D 75 95 A1 85 D5 58 F2 E6 " +
"69 B5 95 67 4F 52 17 C9 96 EE 14 88 84 82 8B E0 FD";
byte[] payload = Hex.decode(helloMessageRaw);
RLPList rlpList = RLP.decode2(payload);
HelloMessage helloMessage = new HelloMessage(rlpList);
helloMessage.parseRLP();
System.out.println(helloMessage);
assertEquals(12, helloMessage.getP2PVersion());
assertEquals("Ethereum(++)/ZeroGox/v0.5.1/ncurses/Linux/g++", helloMessage.getClientId());
assertEquals(7, helloMessage.getCapabilities());
assertEquals(30303, helloMessage.getListenPort());
assertEquals(
"D8833B83560E0B12170E9169DC43784223A59842DE2359E6D03DB34C30A966C2DE3B4B2552FB0D7595A185D558F2E669B595674F5217C996EE148884828BE0FD",
Hex.toHexString(helloMessage.getPeerId()).toUpperCase() );
}
@Test /* HelloMessage 2 */
public void test_2() {
String helloMessageRaw = "F87F800B80B5457468657265756D282B2B292F76302E342E332F4554485F4255494C445F545950452F4554485F4255494C445F504C4154464F524D0782765FB840E02B18FBA6B887FB9258469C3AF8E445CC9AE2B5386CAC5F60C4170F822086224E3876555C745A7EC8AC181C7F9701776D94A779604EA12651DE5F4A748D29E1";
byte[] payload = Hex.decode(helloMessageRaw);
RLPList rlpList = RLP.decode2(payload);
HelloMessage helloMessage = new HelloMessage(rlpList);
helloMessage.parseRLP();
System.out.println(helloMessage);
assertEquals(11, helloMessage.getP2PVersion());
assertEquals("Ethereum(++)/v0.4.3/ETH_BUILD_TYPE/ETH_BUILD_PLATFORM", helloMessage.getClientId());
assertEquals(7, helloMessage.getCapabilities());
assertEquals(30303, helloMessage.getListenPort());
assertEquals(
"E02B18FBA6B887FB9258469C3AF8E445CC9AE2B5386CAC5F60C4170F822086224E3876555C745A7EC8AC181C7F9701776D94A779604EA12651DE5F4A748D29E1",
Hex.toHexString(helloMessage.getPeerId()).toUpperCase() );
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,60 @@
package org.ethereum.net;
import static org.junit.Assert.assertEquals;
import java.net.UnknownHostException;
import java.util.Iterator;
import org.ethereum.net.client.PeerData;
import org.ethereum.net.message.PeersMessage;
import org.ethereum.util.RLP;
import org.ethereum.util.RLPList;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
public class PeersMessageTest {
/* PEERS */
@Test /* PeersMessage 1*/
public void test_5() {
String peersMessageRaw = "F89911F84A84364845B482765FB840430BB21ECF73A54AEF511404948C016532406B371EDABD20A478C3ECD22052A0065A7399A6D19594E24B153930E63A3B12B3BA4F30A3CDA1977D60D4060FFF25F84A845163E11282765FB8405F1DBE5E50E92A6B67377E079D986155C0D82D964E65332F524810ED7831A52837F1C0FB042EA2A25548E3B444C337F54C7547B2D877734E2899F40BFA23ED51";
byte[] payload = Hex.decode(peersMessageRaw);
RLPList rlpList = RLP.decode2(payload);
PeersMessage peersMessage= new PeersMessage(rlpList);
System.out.println(peersMessage);
assertEquals(2, peersMessage.getPeers().size());
Iterator<PeerData> it = peersMessage.getPeers().iterator(); it.next();
PeerData peerData = it.next();
assertEquals("/81.99.225.18", peerData.getInetAddress().toString());
assertEquals(30303, peerData.getPort());
assertEquals("5F1DBE5E50E92A6B67377E079D986155C0D82D964E65332F524810ED7831A52837F1C0FB042EA2A25548E3B444C337F54C7547B2D877734E2899F40BFA23ED51",
Hex.toHexString( peerData.getPeerId() ).toUpperCase());
}
@Test /* Peers msg parsing performance*/
public void test_7() throws UnknownHostException {
long time1 = System.currentTimeMillis();
for (int i = 0; i < 20000; ++i) {
String peersPacketRaw = "F89911F84A84364845B482765FB840430BB21ECF73A54AEF511404948C016532406B371EDABD20A478C3ECD22052A0065A7399A6D19594E24B153930E63A3B12B3BA4F30A3CDA1977D60D4060FFF25F84A845163E11282765FB8405F1DBE5E50E92A6B67377E079D986155C0D82D964E65332F524810ED7831A52837F1C0FB042EA2A25548E3B444C337F54C7547B2D877734E2899F40BFA23ED51";
byte[] payload = Hex.decode(peersPacketRaw);
RLPList rlpList = RLP.decode2(payload);
PeersMessage peersMessage = new PeersMessage(rlpList);
peersMessage.parseRLP();
}
long time2 = System.currentTimeMillis();
System.out.println("20,000 PEERS packets parsing: " + (time2 - time1) + "(msec)");
}
}

View File

@ -0,0 +1,176 @@
package org.ethereum.net;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.ethereum.core.Transaction;
import org.ethereum.crypto.ECKey;
import org.ethereum.crypto.HashUtil;
import org.ethereum.net.message.TransactionsMessage;
import org.ethereum.util.ByteUtil;
import org.ethereum.util.RLP;
import org.ethereum.util.RLPList;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
public class TransactionsMessageTest {
/* TRANSACTIONS */
@Test /* Transactions message 1 */
public void test_8() {
String txsPacketRaw = "f86e12f86b04648609184e72a00094cd2a3d9f938e13cd947ec05abc7fe734df8dd826"
+ "881bc16d674ec80000801ba05c89ebf2b77eeab88251e553f6f9d53badc1d800"
+ "bbac02d830801c2aa94a4c9fa00b7907532b1f29c79942b75fff98822293bf5f"
+ "daa3653a8d9f424c6a3265f06c";
byte[] payload = Hex.decode(txsPacketRaw);
RLPList rlpList = RLP.decode2(payload);
TransactionsMessage transactionsMessage = new TransactionsMessage(rlpList);
System.out.println(transactionsMessage);
assertEquals(1, transactionsMessage.getTransactions().size());
Transaction tx = transactionsMessage.getTransactions().get(0);
assertEquals("5d2aee0490a9228024158433d650335116b4af5a30b8abb10e9b7f9f7e090fd8", Hex.toHexString(tx.getHash()));
assertEquals("04", Hex.toHexString(tx.getNonce()));
assertEquals("1bc16d674ec80000", Hex.toHexString(tx.getValue()));
assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(tx.getReceiveAddress()));
assertEquals("64", Hex.toHexString(tx.getGasPrice()));
assertEquals("09184e72a000", Hex.toHexString(tx.getGasLimit()));
assertEquals("null", ByteUtil.toHexString(tx.getData()));
assertEquals("1b", Hex.toHexString(new byte[] { tx.getSignature().v }));
assertEquals("5c89ebf2b77eeab88251e553f6f9d53badc1d800bbac02d830801c2aa94a4c9f", Hex.toHexString(tx.getSignature().r.toByteArray()));
assertEquals("0b7907532b1f29c79942b75fff98822293bf5fdaa3653a8d9f424c6a3265f06c", Hex.toHexString(tx.getSignature().s.toByteArray()));
}
@Test /* Transactions message 2 */
public void test_9() {
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);
RLPList rlpList = RLP.decode2(payload);
TransactionsMessage transactionsMessage = new TransactionsMessage(rlpList);
System.out.println(transactionsMessage);
assertEquals(3, transactionsMessage.getTransactions().size());
Transaction tx =
transactionsMessage.getTransactions().get(0);
assertEquals("1b9d9456293cbcbc2f28a0fdc67028128ea571b033fb0e21d0ee00bcd6167e5d",
Hex.toHexString(tx.getHash()));
assertEquals("00",
Hex.toHexString(tx.getNonce()));
assertEquals("2710",
Hex.toHexString(tx.getValue()));
assertEquals("09184e72a000",
Hex.toHexString(tx.getReceiveAddress()));
assertNull( tx.getGasPrice() );
assertEquals("0000000000000000000000000000000000000000",
Hex.toHexString(tx.getGasLimit()));
assertEquals("606956330c0d630000003359366000530a0d630000003359602060005301356000533557604060005301600054630000000c58",
Hex.toHexString(tx.getData()));
assertEquals("33",
Hex.toHexString(new byte[] {tx.getSignature().v}));
assertEquals("1c",
Hex.toHexString(tx.getSignature().r.toByteArray()));
assertEquals("7f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402c3c4",
Hex.toHexString(tx.getSignature().s.toByteArray()));
tx = transactionsMessage.getTransactions().get(2);
assertEquals("dde9543921850f41ca88e5401322cd7651c78a1e4deebd5ee385af8ac343f0ad",
Hex.toHexString(tx.getHash()));
assertEquals("02",
Hex.toHexString(tx.getNonce()));
assertEquals("2710",
Hex.toHexString(tx.getValue()));
assertEquals("09184e72a000",
Hex.toHexString(tx.getReceiveAddress()));
assertNull(tx.getGasPrice());
assertEquals("ccdeac59d35627b7de09332e819d5159e7bb7250",
Hex.toHexString(tx.getGasLimit()));
assertEquals("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d0aceee7e5ab874e22ccf8d1a649f59106d74e8",
Hex.toHexString(tx.getData()));
assertEquals("1b",
Hex.toHexString(new byte[] {tx.getSignature().v}));
assertEquals("00d05887574456c6de8f7a0d172342c2cbdd4cf7afe15d9dbb8b75b748ba6791c9",
Hex.toHexString(tx.getSignature().r.toByteArray()));
assertEquals("1e87172a861f6c37b5a9e3a5d0d7393152a7fbe41530e5bb8ac8f35433e5931b",
Hex.toHexString(tx.getSignature().s.toByteArray()));
}
@Test /* Transactions msg encode */
public void test15() throws Exception {
String expected = "f87312f870808b00d3c21bcecceda10000009479b08ad8787060333663d19704909ee7b1903e588609184e72a000824255801ca00f410a70e42b2c9854a8421d32c87c370a2b9fff0a27f9f031bb4443681d73b5a018a7dc4c4f9dee9f3dc35cb96ca15859aa27e219a8e4a8547be6bd3206979858";
BigInteger value = new BigInteger("1000000000000000000000000");
byte[] privKey = HashUtil.sha3("cat".getBytes());
ECKey ecKey = ECKey.fromPrivate(privKey);
byte[] gasPrice= Hex.decode("09184e72a000");
byte[] gas = Hex.decode("4255");
Transaction tx = new Transaction(null, value.toByteArray(),
ecKey.getAddress(), gasPrice, gas, null);
tx.sign(privKey);
tx.getEncoded();
List<Transaction> txList = new ArrayList<Transaction>();
txList.add(tx);
TransactionsMessage transactionsMessage = new TransactionsMessage(txList);
assertEquals(expected, Hex.toHexString( transactionsMessage.getPayload()) );
}
}