mirror of
https://github.com/corda/corda.git
synced 2025-06-16 22:28:15 +00:00
ENT-2439 Fix compression in serialization (#3825)
* ENT-2439 Fix compression in serialization
This commit is contained in:
@ -44,7 +44,6 @@ class TestScheme : AbstractKryoSerializationScheme() {
|
||||
override fun rpcClientKryoPool(context: SerializationContext): KryoPool = throw UnsupportedOperationException()
|
||||
|
||||
override fun rpcServerKryoPool(context: SerializationContext): KryoPool = throw UnsupportedOperationException()
|
||||
|
||||
}
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
@ -89,7 +88,6 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
||||
assertThat(bits.deserialize(factory, context)).isEqualTo(Person("bob", null))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun `serialised form is stable when the same object instance is added to the deserialised object graph`() {
|
||||
val noReferencesContext = context.withoutReferences()
|
||||
@ -356,4 +354,16 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
||||
assertEquals(encodingNotPermittedFormat.format(compression), message)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compression reduces number of bytes significantly`() {
|
||||
class Holder(val holder: ByteArray)
|
||||
|
||||
val obj = Holder(ByteArray(20000))
|
||||
val uncompressedSize = obj.serialize(factory, context.withEncoding(null)).size
|
||||
val compressedSize = obj.serialize(factory, context.withEncoding(CordaSerializationEncoding.SNAPPY)).size
|
||||
// If these need fixing, sounds like Kryo wire format changed and checkpoints might not surive an upgrade.
|
||||
assertEquals(20222, uncompressedSize)
|
||||
assertEquals(1111, compressedSize)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user