Raise HandshakeFailure in transport

Change the exception handling flow.
Raise `SecurityUpgradeFailure` in security_multistream.
This commit is contained in:
mhchia
2019-08-21 15:12:35 +08:00
parent 80452d9589
commit 3e04480d62
6 changed files with 54 additions and 21 deletions

View File

@ -10,6 +10,7 @@ def pubkey_from_protobuf(pubkey_pb: protobuf.PublicKey) -> PublicKey:
# TODO: Test against secp256k1 keys
elif pubkey_pb.key_type == protobuf.Secp256k1:
return Secp256k1PublicKey.from_bytes(pubkey_pb.data)
# TODO: Support `Ed25519` and `ECDSA` in the future?
else:
raise ValueError(
f"unsupported key_type={pubkey_pb.key_type}, data={pubkey_pb.data!r}"