I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit 4c6aa8cf authored by zzz's avatar zzz
Browse files

Tests: Add serialize/deserialize test for STBM/OTBRM

parent 010d1a99
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,9 @@ import net.i2p.data.TunnelId;
import net.i2p.data.i2np.BuildRequestRecord;
import net.i2p.data.i2np.BuildResponseRecord;
import net.i2p.data.i2np.EncryptedBuildRecord;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.data.i2np.I2NPMessageException;
import net.i2p.data.i2np.I2NPMessageHandler;
import net.i2p.data.i2np.OutboundTunnelBuildReplyMessage;
import net.i2p.data.i2np.ShortTunnelBuildMessage;
import net.i2p.data.i2np.TunnelBuildMessage;
......@@ -97,6 +100,17 @@ public class BuildMessageTestStandalone extends TestCase {
"\n" + cfg +
"\n================================================================");
if (testType == 3) {
// test read/write
byte[] data = msg.toByteArray();
try {
I2NPMessage msg2 = (new I2NPMessageHandler(ctx)).readMessage(data);
msg = (ShortTunnelBuildMessage) msg2;
} catch (Exception e) {
log.error("STBM out/in fail", e);
assertTrue(e.toString(), false);
}
}
// now msg is fully encrypted, so lets go through the hops, decrypting and replying
// as necessary
......@@ -193,7 +207,16 @@ public class BuildMessageTestStandalone extends TestCase {
else
otbrm.setRecord(i, msg.getRecord(i));
}
reply = otbrm;
// test read/write
byte[] data = otbrm.toByteArray();
try {
I2NPMessage msg2 = (new I2NPMessageHandler(ctx)).readMessage(data);
reply = (OutboundTunnelBuildReplyMessage) msg2;
} catch (Exception e) {
reply = null;
log.error("OTBRM out/in fail", e);
assertTrue(e.toString(), false);
}
} else {
reply = new TunnelBuildReplyMessage(ctx);
for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment