Various subtle bugfixes/improvements
Replace gnu crypt whirlpool implementation with bouncycastles, which is actually the correct version Record compression type of archives and indexes and rewrite with the same compression Fix bzip compression to use size 100k blocks Fix writing index and archive revisions
This commit is contained in:
@@ -68,7 +68,7 @@ public class DataFileTest
|
||||
File file = folder.newFile();
|
||||
Store store = new Store(folder.getRoot());
|
||||
DataFile df = new DataFile(store, file);
|
||||
DataFileWriteResult res = df.write(42, 0x1FFFF, ByteBuffer.wrap(b), CompressionType.NONE, 0);
|
||||
DataFileWriteResult res = df.write(42, 0x1FFFF, ByteBuffer.wrap(b), CompressionType.BZ2, 42);
|
||||
DataFileReadResult res2 = df.read(42, 0x1FFFF, res.sector, res.compressedLength);
|
||||
byte[] buf = res2.data;
|
||||
Assert.assertArrayEquals(b, buf);
|
||||
@@ -95,11 +95,27 @@ public class DataFileTest
|
||||
try (Store store = new Store(folder.getRoot()))
|
||||
{
|
||||
DataFile df = new DataFile(store, folder.newFile());
|
||||
DataFileWriteResult res = df.write(41, 4, ByteBuffer.wrap("test".getBytes()), CompressionType.BZ2, 0);
|
||||
DataFileWriteResult res = df.write(41, 4, ByteBuffer.wrap("test".getBytes()), CompressionType.BZ2, 5);
|
||||
DataFileReadResult res2 = df.read(41, 4, res.sector, res.compressedLength);
|
||||
byte[] buf = res2.data;
|
||||
String str = new String(buf);
|
||||
Assert.assertEquals("test", str);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrc() throws IOException
|
||||
{
|
||||
File file = folder.newFile();
|
||||
Store store = new Store(folder.getRoot());
|
||||
DataFile df = new DataFile(store, file);
|
||||
DataFileWriteResult res = df.write(42, 3, ByteBuffer.wrap("test".getBytes()), CompressionType.NONE, 42);
|
||||
DataFileReadResult res2 = df.read(42, 3, res.sector, res.compressedLength);
|
||||
byte[] buf = res2.data;
|
||||
String str = new String(buf);
|
||||
Assert.assertEquals("test", str);
|
||||
Assert.assertEquals(res.crc, res2.crc);
|
||||
Assert.assertEquals(42, res2.revision);
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
58
cache/src/test/java/net/runelite/cache/fs/util/WhirlpoolTest.java
vendored
Normal file
58
cache/src/test/java/net/runelite/cache/fs/util/WhirlpoolTest.java
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Adam <Adam@sigterm.info>
|
||||
* 4. Neither the name of the Adam <Adam@sigterm.info> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Adam <Adam@sigterm.info> ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Adam <Adam@sigterm.info> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.cache.fs.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WhirlpoolTest
|
||||
{
|
||||
private static final byte[] result =
|
||||
{
|
||||
92, -33, 60, 4, -28, 24, 54, -39,
|
||||
-11, -85, -123, -74, 6, -107, 32, 36,
|
||||
108, 104, -82, 108, 36, -53, -95, 123,
|
||||
-84, -86, -13, 107, -110, 27, 35, -78,
|
||||
-60, -122, 36, 56, 86, 73, -9, -70,
|
||||
-35, 58, -43, 82, -36, -53, -107, -9,
|
||||
-21, 6, -43, 14, 109, -26, -115, 67,
|
||||
64, 116, 107, 18, 12, 46, -64, 63
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testGetHash()
|
||||
{
|
||||
byte[] data = "runelite".getBytes();
|
||||
byte[] out = Whirlpool.getHash(data, data.length);
|
||||
|
||||
Assert.assertArrayEquals(out, result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user