From 0c9d2c927a719f51fcce5df53d4f7c4a02622091 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 10 Feb 2019 15:57:39 -0800 Subject: [PATCH] fix hashability of dilation objects --- src/wormhole/_dilation/connection.py | 2 +- src/wormhole/_dilation/connector.py | 2 +- src/wormhole/_dilation/manager.py | 2 +- src/wormhole/test/dilate/test_connection.py | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wormhole/_dilation/connection.py b/src/wormhole/_dilation/connection.py index 84205aa..1601b25 100644 --- a/src/wormhole/_dilation/connection.py +++ b/src/wormhole/_dilation/connection.py @@ -455,7 +455,7 @@ class _Record(object): self._framer.send_frame(frame) -@attrs(hash=True) +@attrs(cmp=False) class DilatedConnectionProtocol(Protocol, object): """I manage an L2 connection. diff --git a/src/wormhole/_dilation/connector.py b/src/wormhole/_dilation/connector.py index 42b9bb5..e4b4885 100644 --- a/src/wormhole/_dilation/connector.py +++ b/src/wormhole/_dilation/connector.py @@ -39,7 +39,7 @@ NOISEPROTO = b"Noise_NNpsk0_25519_ChaChaPoly_BLAKE2s" def build_noise(): return NoiseConnection.from_name(NOISEPROTO) -@attrs(hash=True) +@attrs(cmp=False) @implementer(IDilationConnector) class Connector(object): """I manage a single generation of connection. diff --git a/src/wormhole/_dilation/manager.py b/src/wormhole/_dilation/manager.py index d85d31e..c9b2b47 100644 --- a/src/wormhole/_dilation/manager.py +++ b/src/wormhole/_dilation/manager.py @@ -87,7 +87,7 @@ def make_side(): # * if follower calls w.dilate() but not leader, follower waits forever # in "want", leader waits forever in "wanted" -@attrs(hash=True) +@attrs(cmp=False) @implementer(IDilationManager) class Manager(object): _S = attrib(validator=provides(ISend), repr=False) diff --git a/src/wormhole/test/dilate/test_connection.py b/src/wormhole/test/dilate/test_connection.py index 959c5cd..07eab68 100644 --- a/src/wormhole/test/dilate/test_connection.py +++ b/src/wormhole/test/dilate/test_connection.py @@ -29,6 +29,10 @@ def make_con(role, use_relay=False): class Connection(unittest.TestCase): + def test_hashable(self): + c, n, connector, t, eq = make_con(LEADER) + hash(c) + def test_bad_prologue(self): c, n, connector, t, eq = make_con(LEADER) c.makeConnection(t)