Remove tests associated with removed code
This commit is contained in:
parent
bb34f9042e
commit
844723cea9
@ -48,7 +48,6 @@ def get_arguments() -> dict:
|
|||||||
('get-url', 'url', 'get-web'): openwebinterface.get_url,
|
('get-url', 'url', 'get-web'): openwebinterface.get_url,
|
||||||
('addid', 'add-id'): pubkeymanager.add_ID,
|
('addid', 'add-id'): pubkeymanager.add_ID,
|
||||||
('changeid', 'change-id'): pubkeymanager.change_ID,
|
('changeid', 'change-id'): pubkeymanager.change_ID,
|
||||||
('add-vanity', 'addvanity'): pubkeymanager.add_vanity,
|
|
||||||
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
||||||
('soft-reset', 'softreset'): softreset.soft_reset,
|
('soft-reset', 'softreset'): softreset.soft_reset,
|
||||||
('runtime-test', 'runtimetest'): runtimetestcmd.do_runtime_test
|
('runtime-test', 'runtimetest'): runtimetestcmd.do_runtime_test
|
||||||
|
@ -8,7 +8,6 @@ import getpass
|
|||||||
import unpaddedbase32
|
import unpaddedbase32
|
||||||
import niceware
|
import niceware
|
||||||
|
|
||||||
import vanityonionr
|
|
||||||
import logger
|
import logger
|
||||||
import onionrexceptions
|
import onionrexceptions
|
||||||
from onionrutils import stringvalidators, bytesconverter
|
from onionrutils import stringvalidators, bytesconverter
|
||||||
@ -94,43 +93,3 @@ change_ID.onionr_help = "<pubkey>: Switches Onionr to " # type: ignore
|
|||||||
change_ID.onionr_help += "use a different user ID key. " # type: ignore
|
change_ID.onionr_help += "use a different user ID key. " # type: ignore
|
||||||
change_ID.onionr_help += "You should immediately restart " # type: ignore
|
change_ID.onionr_help += "You should immediately restart " # type: ignore
|
||||||
change_ID.onionr_help += "Onionr if it is running." # type: ignore
|
change_ID.onionr_help += "Onionr if it is running." # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def add_vanity():
|
|
||||||
"""Command to generate menmonic vanity key pair."""
|
|
||||||
key_manager = keymanager.KeyManager()
|
|
||||||
|
|
||||||
def tell(tell):
|
|
||||||
return logger.info(tell, terminal=True)
|
|
||||||
|
|
||||||
words = ''
|
|
||||||
length = len(sys.argv) - 2
|
|
||||||
if length == 0:
|
|
||||||
return
|
|
||||||
for i in range(2, len(sys.argv)):
|
|
||||||
words += ' '
|
|
||||||
words += sys.argv[i]
|
|
||||||
try:
|
|
||||||
if length == 1:
|
|
||||||
tell('Finding vanity, this should only take a few moments.')
|
|
||||||
else:
|
|
||||||
tell('Finding vanity, this will probably take a really long time.')
|
|
||||||
try:
|
|
||||||
vanity = vanityonionr.find_multiprocess(words)
|
|
||||||
except ValueError:
|
|
||||||
logger.warn('Vanity words must be valid niceware',
|
|
||||||
terminal=True)
|
|
||||||
else:
|
|
||||||
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
|
||||||
tell('Found vanity address:\n' +
|
|
||||||
'-'.join(niceware.bytes_to_passphrase(vanity[0])))
|
|
||||||
tell('Base32 Public key: %s' % (b32_pub.decode(),))
|
|
||||||
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
add_vanity.onionr_help = "<space separated words> - " # type: ignore
|
|
||||||
add_vanity.onionr_help += "Generates and stores an " # type: ignore
|
|
||||||
add_vanity.onionr_help += "Onionr vanity address " # type: ignore
|
|
||||||
add_vanity.onionr_help += "(see is.gd/YklHGe)" # type: ignore
|
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
"""
|
|
||||||
Onionr Vanity address generator
|
|
||||||
|
|
||||||
Library to generate vanity ed25519 addresses in various encodings
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
Onionr Vanity Address Generator
|
|
||||||
Copyright (C) 2019 Kevin Froman
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import niceware
|
|
||||||
import nacl.signing, nacl.encoding
|
|
||||||
|
|
||||||
import multiprocessing
|
|
||||||
from multiprocessing import Process, Pipe, Queue
|
|
||||||
import re, time
|
|
||||||
import threading
|
|
||||||
|
|
||||||
import logger
|
|
||||||
|
|
||||||
wordlist = niceware.WORD_LIST
|
|
||||||
|
|
||||||
def find_vanity_mnemonic(start_words: str, queue):
|
|
||||||
key_pair = [b"", b""]
|
|
||||||
vanity_key = ""
|
|
||||||
check = 0
|
|
||||||
while not vanity_key.startswith(start_words):
|
|
||||||
key = nacl.signing.SigningKey.generate()
|
|
||||||
key_pair[1] = key.encode(nacl.encoding.RawEncoder)
|
|
||||||
key_pair[0] = key.verify_key.encode(encoder=nacl.encoding.RawEncoder)
|
|
||||||
vanity_key = '-'.join(niceware.bytes_to_passphrase(key_pair[0]))
|
|
||||||
check += 1
|
|
||||||
else:
|
|
||||||
queue.put(key_pair)
|
|
||||||
return key_pair
|
|
||||||
|
|
||||||
def _start(start_words, obj):
|
|
||||||
done = False
|
|
||||||
try:
|
|
||||||
q = Queue()
|
|
||||||
p = Process(target=find_vanity_mnemonic, args=[start_words, q], daemon=True)
|
|
||||||
p.daemon = True
|
|
||||||
p.start()
|
|
||||||
except ImportError:
|
|
||||||
logger.error(
|
|
||||||
"Error in subprocess module when getting new POW " +
|
|
||||||
"pipe.\nThis is related to a problem in 3.9.x", terminal=True)
|
|
||||||
return
|
|
||||||
rec = None
|
|
||||||
while not done:
|
|
||||||
try:
|
|
||||||
if rec == None:
|
|
||||||
rec = q.get(True, 1)
|
|
||||||
except:
|
|
||||||
rec = None
|
|
||||||
if rec != None or obj.done:
|
|
||||||
done = True
|
|
||||||
obj.done = True
|
|
||||||
obj.result = rec
|
|
||||||
return rec
|
|
||||||
|
|
||||||
def handler(start_words: str):
|
|
||||||
obj = lambda test: None
|
|
||||||
obj.done = False
|
|
||||||
for x in range(multiprocessing.cpu_count()):
|
|
||||||
threading.Thread(target=_start, args=[start_words, obj], daemon=True).start()
|
|
||||||
while not obj.done:
|
|
||||||
time.sleep(1)
|
|
||||||
return obj.result
|
|
||||||
|
|
||||||
def find_multiprocess(start_words: str):
|
|
||||||
start_words = start_words.strip()
|
|
||||||
start_words = re.sub(' +', ' ', start_words)
|
|
||||||
test_words = str(start_words)
|
|
||||||
|
|
||||||
for word in test_words.split(' '):
|
|
||||||
for validword in wordlist:
|
|
||||||
if word == validword:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise ValueError('%s not in wordlist' % (word,))
|
|
||||||
return handler(start_words)
|
|
@ -13,6 +13,6 @@ with Popen(['./onionr.sh', 'details'], stdout=PIPE) as onionr_proc:
|
|||||||
if onionr_proc.returncode != 0:
|
if onionr_proc.returncode != 0:
|
||||||
raise ValueError('Raised non zero exit ' + str(onionr_proc.returncode))
|
raise ValueError('Raised non zero exit ' + str(onionr_proc.returncode))
|
||||||
|
|
||||||
for word in ['Node', 'Human-readable']:
|
for word in ['Human-readable']:
|
||||||
if word not in output:
|
if word not in output:
|
||||||
raise ValueError(word + " not in " + output)
|
raise ValueError(word + " not in " + output)
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
from unittest.mock import patch
|
|
||||||
import sys, os
|
|
||||||
sys.path.append(".")
|
|
||||||
sys.path.append("src/")
|
|
||||||
import unittest, uuid
|
|
||||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
||||||
print("Test directory:", TEST_DIR)
|
|
||||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
|
||||||
from utils import createdirs
|
|
||||||
from onionrcommands import parser
|
|
||||||
import onionrsetup as setup
|
|
||||||
from netcontroller.torcontrol import customtorrc
|
|
||||||
from utils import createdirs
|
|
||||||
from onionrsetup import setup_config, setup_default_plugins
|
|
||||||
from coredb import blockmetadb
|
|
||||||
from etc.onionrvalues import BLOCK_EXPORT_FILE_EXT
|
|
||||||
|
|
||||||
createdirs.create_dirs()
|
|
||||||
setup_config()
|
|
||||||
setup_default_plugins()
|
|
||||||
import config
|
|
||||||
from filepaths import export_location
|
|
||||||
|
|
||||||
class OnionrTests(unittest.TestCase):
|
|
||||||
def test_export(self):
|
|
||||||
testargs = ["onionr.py", "circlesend", "tests", "hello"]
|
|
||||||
with patch.object(sys, 'argv', testargs):
|
|
||||||
try:
|
|
||||||
parser.register()
|
|
||||||
except SystemExit:
|
|
||||||
pass
|
|
||||||
bl = blockmetadb.get_block_list()[0]
|
|
||||||
testargs = ["onionr.py", "export-block", bl]
|
|
||||||
with patch.object(sys, 'argv', testargs):
|
|
||||||
parser.register()
|
|
||||||
|
|
||||||
with open(export_location + '/' + bl + BLOCK_EXPORT_FILE_EXT, 'rb') as f:
|
|
||||||
|
|
||||||
if b'hello' not in f.read():
|
|
||||||
raise ValueError('No exported block')
|
|
||||||
|
|
||||||
|
|
||||||
unittest.main()
|
|
@ -1,44 +0,0 @@
|
|||||||
from unittest.mock import patch
|
|
||||||
import sys, os
|
|
||||||
sys.path.append(".")
|
|
||||||
sys.path.append("src/")
|
|
||||||
import unittest, uuid
|
|
||||||
import base64
|
|
||||||
import niceware
|
|
||||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
||||||
print("Test directory:", TEST_DIR)
|
|
||||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
|
||||||
from utils import createdirs
|
|
||||||
from onionrcommands import parser
|
|
||||||
import onionrsetup as setup
|
|
||||||
from utils import createdirs
|
|
||||||
from onionrsetup import setup_config, setup_default_plugins
|
|
||||||
import unpaddedbase32
|
|
||||||
|
|
||||||
createdirs.create_dirs()
|
|
||||||
setup_config()
|
|
||||||
setup_default_plugins()
|
|
||||||
import config
|
|
||||||
from filepaths import keys_file
|
|
||||||
|
|
||||||
class OnionrTests(unittest.TestCase):
|
|
||||||
def test_vanity(self):
|
|
||||||
testargs = ["onionr.py"]
|
|
||||||
with patch.object(sys, 'argv', testargs):
|
|
||||||
try:
|
|
||||||
parser.register()
|
|
||||||
except SystemExit:
|
|
||||||
pass
|
|
||||||
testargs = ["onionr.py", "add-vanity", "jolt"]
|
|
||||||
with patch.object(sys, 'argv', testargs):
|
|
||||||
parser.register()
|
|
||||||
with open(keys_file, 'r') as keys:
|
|
||||||
key_list = keys.read().split('\n')
|
|
||||||
print('vanity key list test key database contents:', key_list)
|
|
||||||
if not niceware.bytes_to_passphrase(unpaddedbase32.b32decode(key_list[1].split(',')[0]))[0].startswith('jolt'):
|
|
||||||
raise ValueError('Vanity generation failed')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unittest.main()
|
|
@ -1,26 +0,0 @@
|
|||||||
import sys, os
|
|
||||||
import uuid
|
|
||||||
sys.path.append(".")
|
|
||||||
sys.path.append("src/")
|
|
||||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
||||||
print("Test directory:", TEST_DIR)
|
|
||||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
|
||||||
import unittest
|
|
||||||
from utils import createdirs
|
|
||||||
createdirs.create_dirs()
|
|
||||||
from onionrcrypto import getourkeypair
|
|
||||||
getourkeypair.get_keypair()
|
|
||||||
import vanityonionr
|
|
||||||
|
|
||||||
import niceware
|
|
||||||
|
|
||||||
wordlist = niceware.WORD_LIST
|
|
||||||
|
|
||||||
class TestBasic(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_basic(self):
|
|
||||||
pair = vanityonionr.find_multiprocess("onion")
|
|
||||||
b = niceware.bytes_to_passphrase(pair[0])
|
|
||||||
self.assertTrue(b[0].startswith("onion"))
|
|
||||||
|
|
||||||
unittest.main()
|
|
Loading…
Reference in New Issue
Block a user