File dir = new File("bootstrap-pull-test");
FileUtil.removeAll(dir);
RandomSource random = NodeStarter.globalTestInit(dir.getPath(), false, LogLevel.ERROR, "", false);
byte[] seed = new byte[64];
random.nextBytes(seed);
MersenneTwister fastRandom = new MersenneTwister(seed);
File seednodes = new File("seednodes.fref");
if(!seednodes.exists() || seednodes.length() == 0 || !seednodes.canRead()) {
System.err.println("Unable to read seednodes.fref, it doesn't exist, or is empty");
System.exit(EXIT_NO_SEEDNODES);
}
File secondInnerDir = new File(dir, Integer.toString(DARKNET_PORT));
secondInnerDir.mkdir();
FileInputStream fis = new FileInputStream(seednodes);
FileUtil.writeTo(fis, new File(secondInnerDir, "seednodes.fref"));
fis.close();
// Create the test data
System.out.println("Creating test data.");
File dataFile = File.createTempFile("testdata", ".tmp", dir);
OutputStream os = new FileOutputStream(dataFile);
byte[] buf = new byte[4096];
for(long written = 0; written < TEST_SIZE;) {
fastRandom.nextBytes(buf);
int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
os.write(buf, 0, toWrite);
written += toWrite;
}
os.close();