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(), + )