py3 porting started on remaining test cases
This commit is contained in:
parent
73c7a09cb9
commit
cc367f7c04
|
@ -10,8 +10,15 @@ from datetime import datetime
|
||||||
from six import string_types
|
from six import string_types
|
||||||
from six.moves import configparser
|
from six.moves import configparser
|
||||||
|
|
||||||
|
try:
|
||||||
import state
|
import state
|
||||||
|
except ImportError:
|
||||||
|
from . import state
|
||||||
|
|
||||||
|
try:
|
||||||
from singleton import Singleton
|
from singleton import Singleton
|
||||||
|
except ImportError:
|
||||||
|
from .singleton import Singleton
|
||||||
|
|
||||||
SafeConfigParser = configparser.SafeConfigParser
|
SafeConfigParser = configparser.SafeConfigParser
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,25 @@ High level cryptographic functions based on `.pyelliptic` OpenSSL bindings.
|
||||||
|
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
|
try:
|
||||||
import pyelliptic
|
import pyelliptic
|
||||||
|
except ImportError:
|
||||||
|
from . import pyelliptic
|
||||||
|
|
||||||
|
try:
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
|
except ImportError:
|
||||||
|
from .bmconfigparser import BMConfigParser
|
||||||
|
|
||||||
|
try:
|
||||||
from pyelliptic import OpenSSL
|
from pyelliptic import OpenSSL
|
||||||
|
except ImportError:
|
||||||
|
from .pyelliptic import OpenSSL
|
||||||
|
|
||||||
|
try:
|
||||||
from pyelliptic import arithmetic as a
|
from pyelliptic import arithmetic as a
|
||||||
|
except ImportError:
|
||||||
|
from .pyelliptic import arithmetic as a
|
||||||
|
|
||||||
|
|
||||||
def makeCryptor(privkey):
|
def makeCryptor(privkey):
|
||||||
|
|
|
@ -13,16 +13,46 @@ import time
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from struct import Struct, pack, unpack
|
from struct import Struct, pack, unpack
|
||||||
|
|
||||||
|
try:
|
||||||
import defaults
|
import defaults
|
||||||
|
except ImportError:
|
||||||
|
from . import defaults
|
||||||
|
try:
|
||||||
import highlevelcrypto
|
import highlevelcrypto
|
||||||
|
except ImportError:
|
||||||
|
from . import highlevelcrypto
|
||||||
|
|
||||||
|
try:
|
||||||
import state
|
import state
|
||||||
|
except ImportError:
|
||||||
|
from . import state
|
||||||
|
|
||||||
|
try:
|
||||||
from addresses import (
|
from addresses import (
|
||||||
encodeVarint, decodeVarint, decodeAddress, varintDecodeError)
|
encodeVarint, decodeVarint, decodeAddress, varintDecodeError)
|
||||||
|
except ImportError:
|
||||||
|
from .addresses import (
|
||||||
|
encodeVarint, decodeVarint, decodeAddress, varintDecodeError)
|
||||||
|
try:
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
|
except ImportError:
|
||||||
|
from .bmconfigparser import BMConfigParser
|
||||||
|
try:
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
except ImportError:
|
||||||
|
from .debug import logger
|
||||||
|
try:
|
||||||
from fallback import RIPEMD160Hash
|
from fallback import RIPEMD160Hash
|
||||||
from helper_sql import sqlExecute
|
except ImportError:
|
||||||
|
from .fallback import RIPEMD160Hash
|
||||||
|
try:
|
||||||
|
from .helper_sql import sqlExecute
|
||||||
|
except ImportError:
|
||||||
|
from .helper_sql import sqlExecute
|
||||||
|
try:
|
||||||
from version import softwareVersion
|
from version import softwareVersion
|
||||||
|
except ImportError:
|
||||||
|
from .version import softwareVersion
|
||||||
|
|
||||||
# Service flags
|
# Service flags
|
||||||
#: This is a normal network node
|
#: This is a normal network node
|
||||||
|
@ -100,6 +130,10 @@ def encodeHost(host):
|
||||||
return '\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode(
|
return '\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode(
|
||||||
host.split(".")[0], True)
|
host.split(".")[0], True)
|
||||||
elif host.find(':') == -1:
|
elif host.find(':') == -1:
|
||||||
|
if sys.version_info[0] == 3:
|
||||||
|
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
||||||
|
str(socket.inet_aton(host))
|
||||||
|
else:
|
||||||
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
||||||
socket.inet_aton(host)
|
socket.inet_aton(host)
|
||||||
return socket.inet_pton(socket.AF_INET6, host)
|
return socket.inet_pton(socket.AF_INET6, host)
|
||||||
|
|
|
@ -4,9 +4,9 @@ Test for ECC blind signatures
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from .common import skip_python3
|
# from .common import skip_python3
|
||||||
|
|
||||||
skip_python3()
|
# skip_python3()
|
||||||
|
|
||||||
from pybitmessage.pyelliptic import ECCBlind, ECCBlindChain, OpenSSL
|
from pybitmessage.pyelliptic import ECCBlind, ECCBlindChain, OpenSSL
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,6 @@ import os
|
||||||
import tempfile
|
import tempfile
|
||||||
from pybitmessage.bmconfigparser import BMConfigParser
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
from .test_process import TestProcessProto
|
from .test_process import TestProcessProto
|
||||||
from .common import skip_python3
|
|
||||||
|
|
||||||
skip_python3()
|
|
||||||
|
|
||||||
|
|
||||||
class TestProcessConfig(TestProcessProto):
|
class TestProcessConfig(TestProcessProto):
|
||||||
|
|
|
@ -3,9 +3,9 @@ Test for network group
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from .common import skip_python3
|
# from .common import skip_python3
|
||||||
|
|
||||||
skip_python3()
|
# skip_python3()
|
||||||
|
|
||||||
|
|
||||||
class TestNetworkGroup(unittest.TestCase):
|
class TestNetworkGroup(unittest.TestCase):
|
||||||
|
@ -17,6 +17,11 @@ class TestNetworkGroup(unittest.TestCase):
|
||||||
from pybitmessage.protocol import network_group
|
from pybitmessage.protocol import network_group
|
||||||
|
|
||||||
test_ip = '1.2.3.4'
|
test_ip = '1.2.3.4'
|
||||||
|
print("network_group(test_ip)")
|
||||||
|
print(network_group(test_ip))
|
||||||
|
if isinstance(network_group(test_ip), bytes):
|
||||||
|
self.assertEqual('\x01\x02', network_group(test_ip).decode('utf-8'))
|
||||||
|
else:
|
||||||
self.assertEqual('\x01\x02', network_group(test_ip))
|
self.assertEqual('\x01\x02', network_group(test_ip))
|
||||||
|
|
||||||
test_ip = '127.0.0.1'
|
test_ip = '127.0.0.1'
|
||||||
|
|
|
@ -9,13 +9,8 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
from .common import cleanup, put_signal_file
|
||||||
from .common import cleanup, put_signal_file, skip_python3
|
|
||||||
|
|
||||||
|
|
||||||
skip_python3()
|
|
||||||
|
|
||||||
|
|
||||||
class TestProcessProto(unittest.TestCase):
|
class TestProcessProto(unittest.TestCase):
|
||||||
|
|
Reference in New Issue
Block a user