diff --git a/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt b/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt index b3954434..9d4b00fb 100644 --- a/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt +++ b/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt @@ -320,6 +320,33 @@ object Js5CompressionTest { } } + @Test + fun testBzip2Corrupt() { + read("bzip2-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + + @Test + fun testGzipCorrupt() { + read("gzip-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + + @Test + fun testLzmaCorrupt() { + read("lzma-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + private fun read(name: String): ByteBuf { Js5CompressionTest::class.java.getResourceAsStream("compression/$name").use { input -> return Unpooled.wrappedBuffer(input.readAllBytes()) diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat new file mode 100644 index 00000000..b6fd1229 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat differ diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat new file mode 100644 index 00000000..c24f0e87 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat differ diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat new file mode 100644 index 00000000..e2754a19 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat differ