From bfd8312ef06035407b52253a186a879536af5568 Mon Sep 17 00:00:00 2001 From: meejah Date: Thu, 15 Apr 2021 19:19:14 -0600 Subject: [PATCH] render empty token correctly --- src/wormhole_transit_relay/server_state.py | 9 +++++---- .../test/test_transit_server.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/wormhole_transit_relay/server_state.py b/src/wormhole_transit_relay/server_state.py index 60ea710..f851b91 100644 --- a/src/wormhole_transit_relay/server_state.py +++ b/src/wormhole_transit_relay/server_state.py @@ -178,10 +178,11 @@ class TransitServerState(object): d = "-" if self._token is not None: d = self._token[:16].decode("ascii") - if self._side is not None: - d += "-" + self._side.decode("ascii") - else: - d += "-" + + if self._side is not None: + d += "-" + self._side.decode("ascii") + else: + d += "-" return d @_machine.input() diff --git a/src/wormhole_transit_relay/test/test_transit_server.py b/src/wormhole_transit_relay/test/test_transit_server.py index c46b936..2b55ef7 100644 --- a/src/wormhole_transit_relay/test/test_transit_server.py +++ b/src/wormhole_transit_relay/test/test_transit_server.py @@ -22,6 +22,7 @@ from ..usage import ( ) from ..transit_server import ( WebSocketTransitConnection, + TransitServerState, ) @@ -677,3 +678,18 @@ class UsageWebSockets(Usage): ) self._pumps.append(pump) return client_protocol + + +class State(unittest.TestCase): + """ + Tests related to server_state.TransitServerState + """ + + def setUp(self): + self.state = TransitServerState(None, None) + + def test_empty_token(self): + self.assertEqual( + "-", + self.state.get_token(), + )