2005-03-03 jrandom
* Loop while starting up the I2PTunnel instances, in case the I2CP listener isn't up yet (thanks detonate!) * Implement custom reusable GZIP streams to both reduce memory churn and prevent the exposure of data in the standard GZIP header (creation time, OS, etc). This is RFC1952 compliant, and backwards compatible, though has only been tested within the confines of I2P's compression use (DataHelper.[de]compress). * Preemptively support the next protocol version, so that after the 0.5.0.2 release, we'll be able to drop protocol=2 to get rid of 0.5 users.
This commit is contained in:
@ -23,6 +23,8 @@ public class DataHelperTest {
|
||||
}
|
||||
|
||||
public void runTests() {
|
||||
// compress
|
||||
testCompress();
|
||||
// long (read/write/to/from)
|
||||
testLong();
|
||||
// date (read/write/to/from)
|
||||
@ -31,7 +33,6 @@ public class DataHelperTest {
|
||||
// properties
|
||||
// boolean
|
||||
// readline
|
||||
// compress
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,6 +154,28 @@ public class DataHelperTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void testCompress() {
|
||||
for (int i = 0; i < 32*1024; i++)
|
||||
testCompress(i);
|
||||
}
|
||||
|
||||
private void testCompress(int size) {
|
||||
byte data[] = new byte[size];
|
||||
_context.random().nextBytes(data);
|
||||
byte compressed[] = DataHelper.compress(data);
|
||||
try {
|
||||
byte decompressed[] = DataHelper.decompress(compressed);
|
||||
boolean ok = DataHelper.eq(data, decompressed);
|
||||
if (!ok)
|
||||
throw new RuntimeException("failed match at size=" + size);
|
||||
else
|
||||
System.out.println("Match at size=" + size);
|
||||
} catch (java.io.IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
throw new RuntimeException("Error at size=" + size +":" + ioe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
DataHelperTest test = new DataHelperTest(I2PAppContext.getGlobalContext());
|
||||
test.runTests();
|
||||
|
Reference in New Issue
Block a user