Make test match reality, and fix corresponding bug.

This commit is contained in:
Itamar Turner-Trauring 2021-05-11 11:39:32 -04:00
parent f1bd7c0b06
commit 9b6067dcd1
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import os
from twisted.trial import unittest
from twisted.internet import defer, error
from six.moves import StringIO
from six import ensure_str
import mock
from ..util import tor_provider
from ..scripts import create_node, runner
@ -185,7 +186,8 @@ class CreateOnion(unittest.TestCase):
protocol)))
txtorcon = mock.Mock()
ehs = mock.Mock()
ehs.private_key = b"privkey"
# This appears to be a native string in the real txtorcon object...
ehs.private_key = ensure_str("privkey")
ehs.hostname = "ONION.onion"
txtorcon.EphemeralHiddenService = mock.Mock(return_value=ehs)
ehs.add_to_tor = mock.Mock(return_value=defer.succeed(None))

View File

@ -211,6 +211,8 @@ def create_config(reactor, cli_config):
"tor_onion.privkey")
privkeyfile = os.path.join(private_dir, "tor_onion.privkey")
with open(privkeyfile, "wb") as f:
if isinstance(privkey, str):
privkey = privkey.encode("ascii")
f.write(privkey)
# tahoe_config_tor: this is a dictionary of keys/values to add to the