From 76e6b85f1afc44e0c09b9a3b4037063b6f62e277 Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Thu, 3 Jun 2021 13:59:57 -0700 Subject: [PATCH] Add a compatibility test for serialized sizes --- tests/test_compatibility.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_compatibility.py b/tests/test_compatibility.py index 9404b34..551d11c 100644 --- a/tests/test_compatibility.py +++ b/tests/test_compatibility.py @@ -242,3 +242,30 @@ def test_signer(implementations): assert _verify_message(umbral1, pk_bytes, signature2_bytes, message) assert _verify_message(umbral2, pk_bytes, signature1_bytes, message) + + +def _measure_sizes(umbral): + + sized_types = [ + umbral.SecretKey, + umbral.SecretKeyFactory, + umbral.PublicKey, + umbral.Signature, + umbral.Capsule, + umbral.KeyFrag, + umbral.VerifiedKeyFrag, + umbral.CapsuleFrag, + umbral.VerifiedCapsuleFrag, + ] + + return {tp.__name__: tp.serialized_size() for tp in sized_types} + + +def test_serialization_size(implementations): + + umbral1, umbral2 = implementations + + sizes1 = _measure_sizes(umbral1) + sizes2 = _measure_sizes(umbral1) + + assert sizes1 == sizes2