forked from I2P_Developers/i2p.i2p
Turn BuildMessageTest into a JUnit TestCase
This commit is contained in:
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.Base64;
|
import net.i2p.data.Base64;
|
||||||
import net.i2p.data.ByteArray;
|
import net.i2p.data.ByteArray;
|
||||||
@@ -22,21 +24,14 @@ import net.i2p.util.Log;
|
|||||||
* during transmission), inject replies, then handle the TunnelBuildReplyMessage (unwrapping
|
* during transmission), inject replies, then handle the TunnelBuildReplyMessage (unwrapping
|
||||||
* the reply encryption and reading the replies).
|
* the reply encryption and reading the replies).
|
||||||
*/
|
*/
|
||||||
public class BuildMessageTest {
|
public class BuildMessageTest extends TestCase {
|
||||||
private Hash _peers[];
|
private Hash _peers[];
|
||||||
private PrivateKey _privKeys[];
|
private PrivateKey _privKeys[];
|
||||||
private PublicKey _pubKeys[];
|
private PublicKey _pubKeys[];
|
||||||
private Hash _replyRouter;
|
private Hash _replyRouter;
|
||||||
private long _replyTunnel;
|
private long _replyTunnel;
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public void testBuildMessage() {
|
||||||
BuildMessageTest test = new BuildMessageTest();
|
|
||||||
try {
|
|
||||||
test.runTest();
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTest() {
|
|
||||||
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||||
Log log = ctx.logManager().getLog(getClass());
|
Log log = ctx.logManager().getLog(getClass());
|
||||||
|
|
||||||
@@ -72,10 +67,8 @@ public class BuildMessageTest {
|
|||||||
// this not only decrypts the current hop's record, but encrypts the other records
|
// this not only decrypts the current hop's record, but encrypts the other records
|
||||||
// with the reply key
|
// with the reply key
|
||||||
BuildRequestRecord req = proc.decrypt(ctx, msg, _peers[i], _privKeys[i]);
|
BuildRequestRecord req = proc.decrypt(ctx, msg, _peers[i], _privKeys[i]);
|
||||||
if (req == null) {
|
// If false, no records matched the _peers[i], or the decryption failed
|
||||||
// no records matched the _peers[i], or the decryption failed
|
assertTrue("foo @ " + i, req != null);
|
||||||
throw new RuntimeException("foo @ " + i);
|
|
||||||
}
|
|
||||||
long ourId = req.readReceiveTunnelId();
|
long ourId = req.readReceiveTunnelId();
|
||||||
byte replyIV[] = req.readReplyIV();
|
byte replyIV[] = req.readReplyIV();
|
||||||
long nextId = req.readNextTunnelId();
|
long nextId = req.readNextTunnelId();
|
||||||
|
Reference in New Issue
Block a user