mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 14:40:53 +00:00
Interop tests updated and fixed.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from noise.backends.default.keypairs import KeyPair as NoiseKeyPair
|
||||
from noise.connection import Keypair as NoiseKeypairEnum
|
||||
from noise.connection import NoiseConnection as NoiseState
|
||||
@ -88,7 +89,7 @@ class PatternXX(BasePattern):
|
||||
await read_writer.write_msg(msg_2)
|
||||
|
||||
# Receive and consume msg#3.
|
||||
msg_3 = await read_writer.read_msg(prefix_encoded=True)
|
||||
msg_3 = await read_writer.read_msg()
|
||||
peer_handshake_payload = NoiseHandshakePayload.deserialize(msg_3)
|
||||
|
||||
if handshake_state.rs is None:
|
||||
@ -156,7 +157,7 @@ class PatternXX(BasePattern):
|
||||
# Send msg#3, which includes our encrypted payload and our noise static key.
|
||||
our_payload = self.make_handshake_payload()
|
||||
msg_3 = our_payload.serialize()
|
||||
await read_writer.write_msg(msg_3, prefix_encoded=True)
|
||||
await read_writer.write_msg(msg_3)
|
||||
|
||||
if not noise_state.handshake_finished:
|
||||
raise HandshakeHasNotFinished(
|
||||
@ -175,9 +176,9 @@ class PatternXX(BasePattern):
|
||||
@staticmethod
|
||||
def _get_pubkey_from_noise_keypair(key_pair: NoiseKeyPair) -> PublicKey:
|
||||
# Use `Ed25519PublicKey` since 25519 is used in our pattern.
|
||||
# NOTE: Ignore the warning for now, since it is also not fixed in `noiseprotocol`.
|
||||
# "CryptographyDeprecationWarning: public_bytes now requires
|
||||
# encoding and format arguments. Support for calling without arguments will be
|
||||
# removed in cryptography 2.7"
|
||||
raw_bytes = key_pair.public.public_bytes()
|
||||
raw_bytes = key_pair.public.public_bytes(
|
||||
# ignore "'Type[...]' has no attribute 'Raw'"
|
||||
serialization.Encoding.Raw, # type: ignore
|
||||
serialization.PublicFormat.Raw, # type: ignore
|
||||
)
|
||||
return Ed25519PublicKey.from_bytes(raw_bytes)
|
||||
|
||||
@ -8,6 +8,8 @@ import trio
|
||||
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr
|
||||
from libp2p.security.noise.transport import PROTOCOL_ID as NOISE_PROTOCOL_ID
|
||||
from libp2p.security.secio.transport import ID as SECIO_PROTOCOL_ID
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
from .constants import LOCALHOST_IP
|
||||
@ -27,8 +29,11 @@ class P2PDProcess(BaseInteractiveProcess):
|
||||
is_pubsub_signing: bool = False,
|
||||
is_pubsub_signing_strict: bool = False,
|
||||
) -> None:
|
||||
# NOTE: To support `-security`, we need to hack `go-libp2p-daemon`.
|
||||
args = [f"-listen={control_maddr!s}", f"-security={security_protocol}"]
|
||||
args = [f"-listen={control_maddr!s}"]
|
||||
if security_protocol == SECIO_PROTOCOL_ID:
|
||||
args.append("-secio")
|
||||
if security_protocol == NOISE_PROTOCOL_ID:
|
||||
args.append("-noise")
|
||||
if is_pubsub_enabled:
|
||||
args.append("-pubsub")
|
||||
if is_gossipsub:
|
||||
|
||||
Reference in New Issue
Block a user