From 4c4b5d081be5a8e7daa5736ad92c1ebb2b364daa Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 25 Sep 2015 12:47:15 -0700 Subject: [PATCH] RelayServer: use in-memory DB for tests This avoids problems where a leftover DB from one run causes "wrong code" errors in the next. --- src/wormhole/servers/cmd_server.py | 3 ++- src/wormhole/servers/relay.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wormhole/servers/cmd_server.py b/src/wormhole/servers/cmd_server.py index a894ed5..b7864ad 100644 --- a/src/wormhole/servers/cmd_server.py +++ b/src/wormhole/servers/cmd_server.py @@ -10,7 +10,8 @@ class MyPlugin: # accept --reactor= selection from .relay import RelayServer return RelayServer(self.args.rendezvous, self.args.transit, - self.args.advertise_version) + self.args.advertise_version, + "relay.sqlite") def start_server(args): from twisted.python import usage diff --git a/src/wormhole/servers/relay.py b/src/wormhole/servers/relay.py index 3a6fd7c..cf25183 100644 --- a/src/wormhole/servers/relay.py +++ b/src/wormhole/servers/relay.py @@ -383,9 +383,10 @@ class Root(resource.Resource): self.putChild("", static.Data("Wormhole Relay\n", "text/plain")) class RelayServer(service.MultiService): - def __init__(self, relayport, transitport, advertise_version): + def __init__(self, relayport, transitport, advertise_version, + db_url=":memory:"): service.MultiService.__init__(self) - self.db = get_db("relay.sqlite") + self.db = get_db(db_url) welcome = { "current_version": __version__, # adding .motd will cause all clients to display the message,