def test_deserialized_wait_certificate(self): wait_timer = \ EnclaveWaitTimer( validator_address='1600 Pennsylvania Avenue NW', duration=3.14159, previous_certificate_id='Smart, Maxwell Smart', local_mean=2.71828) wait_certificate = \ EnclaveWaitCertificate.wait_certificate_with_wait_timer( wait_timer=wait_timer, nonce='Eeny, meeny, miny, moe.', block_hash='Indigestion. Pepto Bismol.') serialized = wait_certificate.serialize() private_key = self._create_random_key() wait_certificate.signature = \ create_context('secp256k1').sign(serialized.encode(), private_key) copy_wait_certificate = \ EnclaveWaitCertificate.wait_certificate_from_serialized( serialized, wait_certificate.signature) self.assertAlmostEqual( wait_certificate.request_time, copy_wait_certificate.request_time) self.assertAlmostEqual( wait_certificate.duration, copy_wait_certificate.duration) self.assertEqual( wait_certificate.previous_certificate_id, copy_wait_certificate.previous_certificate_id) self.assertAlmostEqual( wait_certificate.local_mean, copy_wait_certificate.local_mean) self.assertEqual( wait_certificate.validator_address, copy_wait_certificate.validator_address) self.assertEqual( wait_certificate.nonce, copy_wait_certificate.nonce) self.assertEqual( wait_certificate.block_hash, copy_wait_certificate.block_hash) self.assertEqual( wait_certificate.signature, copy_wait_certificate.signature) self.assertEqual(serialized, copy_wait_certificate.serialize())
def test_deserialized_wait_certificate(self): wait_timer = \ EnclaveWaitTimer( validator_address='1600 Pennsylvania Avenue NW', duration=3.14159, previous_certificate_id='Smart, Maxwell Smart', local_mean=2.71828) wait_certificate = \ EnclaveWaitCertificate.wait_certificate_with_wait_timer( wait_timer=wait_timer, nonce='Eeny, meeny, miny, moe.', block_hash='Indigestion. Pepto Bismol.') serialized = wait_certificate.serialize() signing_key = self._create_random_key() wait_certificate.signature = \ signing.sign(serialized, signing_key) copy_wait_certificate = \ EnclaveWaitCertificate.wait_certificate_from_serialized( serialized, wait_certificate.signature) self.assertAlmostEqual( wait_certificate.request_time, copy_wait_certificate.request_time) self.assertAlmostEqual( wait_certificate.duration, copy_wait_certificate.duration) self.assertEqual( wait_certificate.previous_certificate_id, copy_wait_certificate.previous_certificate_id) self.assertAlmostEqual( wait_certificate.local_mean, copy_wait_certificate.local_mean) self.assertEqual( wait_certificate.validator_address, copy_wait_certificate.validator_address) self.assertEqual( wait_certificate.nonce, copy_wait_certificate.nonce) self.assertEqual( wait_certificate.block_hash, copy_wait_certificate.block_hash) self.assertEqual( wait_certificate.signature, copy_wait_certificate.signature) self.assertEqual(serialized, copy_wait_certificate.serialize())
def deserialize_wait_certificate(cls, serialized_certificate, signature): return \ EnclaveWaitCertificate.wait_certificate_from_serialized( serialized_certificate=serialized_certificate, signature=signature)
def deserialize_wait_certificate(cls, serialized_certificate, signature): return \ EnclaveWaitCertificate.wait_certificate_from_serialized( serialized_certificate=serialized_certificate, signature=signature)