innerDir.mkdir();
FileInputStream fis = new FileInputStream(seednodes);
FileUtil.writeTo(fis, new File(innerDir, "seednodes.fref"));
fis.close();
// Create one node
Executor executor = new PooledExecutor();
node = NodeStarter.createTestNode(DARKNET_PORT1, OPENNET_PORT1, dir.getPath(), false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, true, true, true, true, true, true, 12*1024, false, true, false, false, ipOverride);
//NodeCrypto.DISABLE_GROUP_STRIP = true;
//Logger.setupStdoutLogging(LogLevel.MINOR, "freenet:NORMAL,freenet.node.NodeDispatcher:MINOR,freenet.node.FNPPacketMangler:MINOR");
Logger.getChain().setThreshold(LogLevel.ERROR); // kill logging
// Start it
node.start(true);
if (!TestUtil.waitForNodes(node)) {
node.park();
System.exit(EXIT_FAILED_TARGET);
}
System.err.println("Creating test data: "+TEST_SIZE+" bytes.");
RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
OutputStream os = data.getOutputStream();
try {
byte[] buf = new byte[4096];
for(long written = 0; written < TEST_SIZE;) {
node.fastWeakRandom.nextBytes(buf);
int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
os.write(buf, 0, toWrite);
written += toWrite;
}
} finally {
os.close();
}
System.err.println("Inserting test data.");
HighLevelSimpleClient client = node.clientCore.makeClient((short)0, false, false);
InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
long startInsertTime = System.currentTimeMillis();
FreenetURI uri;
try {
uri = client.insert(block, false, null);
} catch (InsertException e) {
System.err.println("INSERT FAILED: "+e);
e.printStackTrace();
System.exit(EXIT_INSERT_FAILED);
return;
}
long endInsertTime = System.currentTimeMillis();
System.err.println("RESULT: Insert took "+(endInsertTime-startInsertTime)+"ms ("+TimeUtil.formatTime(endInsertTime-startInsertTime)+") to "+uri+" .");
node.park();
// Bootstrap a second node.
File secondInnerDir = new File(dir, Integer.toString(DARKNET_PORT2));
secondInnerDir.mkdir();
fis = new FileInputStream(seednodes);
FileUtil.writeTo(fis, new File(secondInnerDir, "seednodes.fref"));
fis.close();
executor = new PooledExecutor();
secondNode = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 5*1024*1024, true, true, true, true, true, true, true, 12*1024, false, true, false, false, ipOverride);
secondNode.start(true);
if (!TestUtil.waitForNodes(secondNode)) {
secondNode.park();
System.exit(EXIT_FAILED_TARGET);