use of net.i2p.data.TunnelId in project i2p.i2p by i2p.
the class FragmentTest method createPending.
protected PendingGatewayMessage createPending(int size, boolean includeRouter, boolean includeTunnel) {
DataMessage m = new DataMessage(_context);
byte[] data = new byte[size];
_context.random().nextBytes(data);
m.setData(data);
m.setUniqueId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
m.setMessageExpiration(_context.clock().now() + 60 * 1000);
Hash toRouter = null;
TunnelId toTunnel = null;
if (includeRouter) {
toRouter = new Hash(new byte[Hash.HASH_LENGTH]);
_context.random().nextBytes(toRouter.getData());
}
if (includeTunnel)
toTunnel = new TunnelId(1 + _context.random().nextLong(TunnelId.MAX_ID_VALUE));
return new PendingGatewayMessage(m, toRouter, toTunnel);
}
use of net.i2p.data.TunnelId in project i2p.i2p by i2p.
the class LocalClientMessageEventListener method startCreateSessionJob.
/**
* Immediately send a fake leaseset
*/
@Override
protected void startCreateSessionJob(SessionConfig config) {
long exp = _context.clock().now() + 10 * 60 * 1000;
LeaseSet ls = new LeaseSet();
Lease lease = new Lease();
lease.setGateway(Hash.FAKE_HASH);
TunnelId id = new TunnelId(1);
lease.setTunnelId(id);
Date date = new Date(exp);
lease.setEndDate(date);
ls.addLease(lease);
_runner.requestLeaseSet(config.getDestination().calculateHash(), ls, exp, null, null);
}
use of net.i2p.data.TunnelId in project i2p.i2p by i2p.
the class GatewayITBase method testTunnel.
@Test
public void testTunnel() throws Exception {
int runCount = 1;
List<DataMessage> messages = new ArrayList<DataMessage>(runCount);
long start = _context.clock().now();
for (int i = 0; i < runCount; i++) {
DataMessage m = getTestMessage(64);
Hash to = new Hash(new byte[Hash.HASH_LENGTH]);
java.util.Arrays.fill(to.getData(), (byte) 0xFF);
TunnelId tunnel = new TunnelId(42);
byte[] data = m.toByteArray();
messages.add(m);
_gw.add(m, to, tunnel);
}
Thread.sleep(1000);
List<I2NPMessage> received = _receiver.clearReceived();
for (int i = 0; i < messages.size(); i++) {
assertTrue(received.contains(((I2NPMessage) messages.get(i))));
}
}
Aggregations