Compare commits
5 Commits
cis-muzahi
...
v0.6
Author | SHA1 | Date |
---|---|---|
cis-kuldeep | 1c6d4702c0 | |
Muzahid | f5fba7d1a8 | |
Muzahid | f075d27fae | |
Muzahid | 1b8dc18ef6 | |
Muzahid | 06cab993d9 |
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "packages/flatpak/shared-modules"]
|
||||||
|
path = packages/flatpak/shared-modules
|
||||||
|
url = https://github.com/flathub/shared-modules.git
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"id": "org.bitmessage.BaseApp",
|
||||||
|
"branch": "19.08",
|
||||||
|
"runtime": "org.freedesktop.Platform",
|
||||||
|
"sdk": "org.freedesktop.Sdk",
|
||||||
|
"runtime-version": "19.08",
|
||||||
|
"separate-locales": false,
|
||||||
|
"modules": [
|
||||||
|
"shared-modules/python2.7/python-2.7.json",
|
||||||
|
"shared-modules/qt4/qt4-4.8.7-minimal.json",
|
||||||
|
{
|
||||||
|
"name": "python-sip",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "archive",
|
||||||
|
"url": "https://www.riverbankcomputing.com/static/Downloads/sip/4.19.25/sip-4.19.25.tar.gz",
|
||||||
|
"sha256": "b39d93e937647807bac23579edbff25fe46d16213f708370072574ab1f1b4211"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildsystem": "simple",
|
||||||
|
"build-commands": [
|
||||||
|
"python configure.py --sip-module PyQt4.sip --no-dist-info",
|
||||||
|
"make",
|
||||||
|
"make install"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "python-qt4",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "archive",
|
||||||
|
"url": "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz",
|
||||||
|
"sha256": "a00f5abef240a7b5852b7924fa5fdf5174569525dc076cd368a566619e56d472"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildsystem": "simple",
|
||||||
|
"build-commands": [
|
||||||
|
"python configure.py -w --confirm-license",
|
||||||
|
"make",
|
||||||
|
"make install"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "PyBitmessage-dependencies",
|
||||||
|
"buildsystem" : "simple",
|
||||||
|
"build-options": {
|
||||||
|
"build-args": [
|
||||||
|
"--share=network"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"build-commands": [
|
||||||
|
"pip --version",
|
||||||
|
"pip install setuptools msgpack"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
"app-id": "org.bitmessage.PyBitmessage",
|
||||||
|
"runtime": "org.freedesktop.Platform",
|
||||||
|
"runtime-version": "19.08",
|
||||||
|
"branch": "stable",
|
||||||
|
"sdk": "org.freedesktop.Sdk",
|
||||||
|
"base": "org.bitmessage.BaseApp",
|
||||||
|
"command": "pybitmessage",
|
||||||
|
"base-version":"stable",
|
||||||
|
"finish-args" : [
|
||||||
|
"--share=network",
|
||||||
|
"--socket=x11",
|
||||||
|
"--share=ipc",
|
||||||
|
"--filesystem=xdg-config/PyBitmessage:create"
|
||||||
|
],
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"name" : "PyBitmessage",
|
||||||
|
"buildsystem" : "simple",
|
||||||
|
"build-options": {
|
||||||
|
"build-args": [
|
||||||
|
"--share=network"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"build-commands": [
|
||||||
|
"python --version",
|
||||||
|
"pwd",
|
||||||
|
"ls",
|
||||||
|
"python checkdeps.py",
|
||||||
|
"python setup.py install --prefix=/app --exec-prefix=/app",
|
||||||
|
"sed -i 's~/usr/bin/~/app/bin/~' /app/bin/pybitmessage",
|
||||||
|
"cat /app/bin/pybitmessage",
|
||||||
|
"mv /app/share/applications/pybitmessage.desktop /app/share/applications/org.bitmessage.PyBitmessage.desktop",
|
||||||
|
"sed -i 's~Icon=pybitmessage~Icon=org.bitmessage.PyBitmessage~' /app/share/applications/org.bitmessage.PyBitmessage.desktop",
|
||||||
|
"mv /app/share/icons/hicolor/scalable/apps/pybitmessage.svg /app/share/icons/hicolor/scalable/apps/org.bitmessage.PyBitmessage.svg",
|
||||||
|
"mv /app/share/icons/hicolor/24x24/apps/pybitmessage.png /app/share/icons/hicolor/24x24/apps/org.bitmessage.PyBitmessage.png",
|
||||||
|
"which pybitmessage"
|
||||||
|
],
|
||||||
|
"sources" : [
|
||||||
|
{
|
||||||
|
"type" : "dir",
|
||||||
|
"path" : "../../"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit fd4d38328ccb078b88ad4a891807e593ae8de806
|
|
@ -2,13 +2,22 @@
|
||||||
BMConfigParser class definition and default configuration settings
|
BMConfigParser class definition and default configuration settings
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ConfigParser
|
import sys
|
||||||
|
if sys.version_info[0] == 3:
|
||||||
|
# python 3
|
||||||
|
import configparser as ConfigParser
|
||||||
|
SafeConfigParser = ConfigParser.ConfigParser
|
||||||
|
else:
|
||||||
|
# python 2
|
||||||
|
import ConfigParser
|
||||||
|
SafeConfigParser = ConfigParser.SafeConfigParser
|
||||||
|
|
||||||
|
import state
|
||||||
|
from singleton import Singleton
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import state
|
|
||||||
from singleton import Singleton
|
|
||||||
|
|
||||||
BMConfigDefaults = {
|
BMConfigDefaults = {
|
||||||
"bitmessagesettings": {
|
"bitmessagesettings": {
|
||||||
|
@ -43,7 +52,8 @@ BMConfigDefaults = {
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class BMConfigParser(ConfigParser.SafeConfigParser):
|
class BMConfigParser(SafeConfigParser):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
|
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
|
||||||
with additional methods specific to bitmessage config.
|
with additional methods specific to bitmessage config.
|
||||||
|
@ -60,26 +70,47 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
|
||||||
raise ValueError("Invalid value %s" % value)
|
raise ValueError("Invalid value %s" % value)
|
||||||
return ConfigParser.ConfigParser.set(self, section, option, value)
|
return ConfigParser.ConfigParser.set(self, section, option, value)
|
||||||
|
|
||||||
def get(self, section, option, raw=False, variables=None):
|
def get(self, section, option, raw=False, vars=None):
|
||||||
# pylint: disable=arguments-differ
|
if sys.version_info[0] == 3:
|
||||||
try:
|
# pylint: disable=arguments-differ
|
||||||
if section == "bitmessagesettings" and option == "timeformat":
|
try:
|
||||||
|
if section == "bitmessagesettings" and option == "timeformat":
|
||||||
|
return ConfigParser.ConfigParser.get(
|
||||||
|
self, section, option)
|
||||||
|
try:
|
||||||
|
return self._temp[section][option]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
return ConfigParser.ConfigParser.get(
|
return ConfigParser.ConfigParser.get(
|
||||||
self, section, option, raw, variables)
|
self, section, option)
|
||||||
|
except ConfigParser.InterpolationError:
|
||||||
|
return ConfigParser.ConfigParser.get(
|
||||||
|
self, section, option)
|
||||||
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
||||||
|
try:
|
||||||
|
return BMConfigDefaults[section][option]
|
||||||
|
except (KeyError, ValueError, AttributeError):
|
||||||
|
raise e
|
||||||
|
else:
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
try:
|
try:
|
||||||
return self._temp[section][option]
|
if section == "bitmessagesettings" and option == "timeformat":
|
||||||
except KeyError:
|
return ConfigParser.ConfigParser.get(
|
||||||
pass
|
self, section, option, raw, vars)
|
||||||
return ConfigParser.ConfigParser.get(
|
try:
|
||||||
self, section, option, True, variables)
|
return self._temp[section][option]
|
||||||
except ConfigParser.InterpolationError:
|
except KeyError:
|
||||||
return ConfigParser.ConfigParser.get(
|
pass
|
||||||
self, section, option, True, variables)
|
return ConfigParser.ConfigParser.get(
|
||||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
self, section, option, True, vars)
|
||||||
try:
|
except ConfigParser.InterpolationError:
|
||||||
return BMConfigDefaults[section][option]
|
return ConfigParser.ConfigParser.get(
|
||||||
except (KeyError, ValueError, AttributeError):
|
self, section, option, True, vars)
|
||||||
raise e
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
||||||
|
try:
|
||||||
|
return BMConfigDefaults[section][option]
|
||||||
|
except (KeyError, ValueError, AttributeError):
|
||||||
|
raise e
|
||||||
|
|
||||||
def setTemp(self, section, option, value=None):
|
def setTemp(self, section, option, value=None):
|
||||||
"""Temporary set option to value, not saving."""
|
"""Temporary set option to value, not saving."""
|
||||||
|
@ -191,3 +222,4 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
|
||||||
if value < 0 or value > 8:
|
if value < 0 or value > 8:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import sqlite3
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import helper_sql
|
import helper_sql
|
||||||
import helper_startup
|
import helper_startup
|
||||||
import paths
|
import paths
|
||||||
|
@ -17,7 +18,6 @@ import tr
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
# pylint: disable=attribute-defined-outside-init,protected-access
|
# pylint: disable=attribute-defined-outside-init,protected-access
|
||||||
from addresses import encodeAddress
|
|
||||||
|
|
||||||
|
|
||||||
class sqlThread(threading.Thread):
|
class sqlThread(threading.Thread):
|
||||||
|
@ -35,9 +35,6 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
self.cur.execute('PRAGMA secure_delete = true')
|
self.cur.execute('PRAGMA secure_delete = true')
|
||||||
|
|
||||||
# call create_function for encode address
|
|
||||||
self.create_function()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TABLE inbox (msgid blob, toaddress text, fromaddress text, subject text,'''
|
'''CREATE TABLE inbox (msgid blob, toaddress text, fromaddress text, subject text,'''
|
||||||
|
@ -328,7 +325,6 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
# We'll also need a `sleeptill` field and a `ttl` field. Also we
|
# We'll also need a `sleeptill` field and a `ttl` field. Also we
|
||||||
# can combine the pubkeyretrynumber and msgretrynumber into one.
|
# can combine the pubkeyretrynumber and msgretrynumber into one.
|
||||||
|
|
||||||
item = '''SELECT value FROM settings WHERE key='version';'''
|
item = '''SELECT value FROM settings WHERE key='version';'''
|
||||||
parameters = ''
|
parameters = ''
|
||||||
self.cur.execute(item, parameters)
|
self.cur.execute(item, parameters)
|
||||||
|
@ -362,11 +358,16 @@ class sqlThread(threading.Thread):
|
||||||
logger.debug('In messages.dat database, adding address field to the pubkeys table.')
|
logger.debug('In messages.dat database, adding address field to the pubkeys table.')
|
||||||
# We're going to have to calculate the address for each row in the pubkeys
|
# We're going to have to calculate the address for each row in the pubkeys
|
||||||
# table. Then we can take out the hash field.
|
# table. Then we can take out the hash field.
|
||||||
self.cur.execute('''ALTER TABLE pubkeys ADD address text DEFAULT '' ;''')
|
self.cur.execute('''ALTER TABLE pubkeys ADD address text DEFAULT '' ''')
|
||||||
|
self.cur.execute('''SELECT hash, addressversion FROM pubkeys''')
|
||||||
# replica for loop to update hashed address
|
queryResult = self.cur.fetchall()
|
||||||
self.cur.execute('''UPDATE pubkeys SET address=(enaddr(pubkeys.addressversion, 1, hash)) WHERE hash=pubkeys.hash; ''')
|
from addresses import encodeAddress
|
||||||
|
for row in queryResult:
|
||||||
|
addressHash, addressVersion = row
|
||||||
|
address = encodeAddress(addressVersion, 1, hash)
|
||||||
|
item = '''UPDATE pubkeys SET address=? WHERE hash=?;'''
|
||||||
|
parameters = (address, addressHash)
|
||||||
|
self.cur.execute(item, parameters)
|
||||||
# Now we can remove the hash field from the pubkeys table.
|
# Now we can remove the hash field from the pubkeys table.
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TEMPORARY TABLE pubkeys_backup'''
|
'''CREATE TEMPORARY TABLE pubkeys_backup'''
|
||||||
|
@ -621,12 +622,3 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
helper_sql.sqlReturnQueue.put((self.cur.fetchall(), rowcount))
|
helper_sql.sqlReturnQueue.put((self.cur.fetchall(), rowcount))
|
||||||
# helper_sql.sqlSubmitQueue.task_done()
|
# helper_sql.sqlSubmitQueue.task_done()
|
||||||
|
|
||||||
def create_function(self):
|
|
||||||
# create_function
|
|
||||||
try:
|
|
||||||
self.conn.create_function("enaddr", 3, func=encodeAddress, deterministic=True)
|
|
||||||
except (TypeError, sqlite3.NotSupportedError) as err:
|
|
||||||
logger.debug(
|
|
||||||
"Got error while pass deterministic in sqlite create function {}, Passing 3 params".format(err))
|
|
||||||
self.conn.create_function("enaddr", 3, encodeAddress)
|
|
||||||
|
|
|
@ -16,16 +16,9 @@ SQLite objects can only be used from one thread.
|
||||||
or isn't thread-safe.
|
or isn't thread-safe.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import Queue
|
||||||
# import Queue
|
|
||||||
try:
|
|
||||||
import queue as Queue #python3
|
|
||||||
except ImportError:
|
|
||||||
import Queue #python2
|
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
sqlSubmitQueue = Queue.Queue()
|
sqlSubmitQueue = Queue.Queue()
|
||||||
"""the queue for SQL"""
|
"""the queue for SQL"""
|
||||||
sqlReturnQueue = Queue.Queue()
|
sqlReturnQueue = Queue.Queue()
|
||||||
|
@ -112,15 +105,6 @@ def sqlExecute(sql_statement, *args):
|
||||||
return rowcount
|
return rowcount
|
||||||
|
|
||||||
|
|
||||||
def sqlExecuteScript(sql_statement):
|
|
||||||
"""Execute SQL script statement"""
|
|
||||||
|
|
||||||
statements = sql_statement.split(";")
|
|
||||||
with SqlBulkExecute() as sql:
|
|
||||||
for q in statements:
|
|
||||||
sql.execute("{}".format(q))
|
|
||||||
|
|
||||||
|
|
||||||
def sqlStoredProcedure(procName):
|
def sqlStoredProcedure(procName):
|
||||||
"""Schedule procName to be run"""
|
"""Schedule procName to be run"""
|
||||||
assert sql_available
|
assert sql_available
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
CREATE TABLE `testhash` (
|
|
||||||
`addressversion` int DEFAULT NULL,
|
|
||||||
`hash` blob DEFAULT NULL,
|
|
||||||
`address` text DEFAULT NULL,
|
|
||||||
UNIQUE(address) ON CONFLICT IGNORE
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO testhash (addressversion, hash) VALUES(4, "21122112211221122112");
|
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
Various tests for config
|
Various tests for config
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
|
||||||
|
|
||||||
from .test_process import TestProcessProto
|
|
||||||
from pybitmessage.bmconfigparser import BMConfigParser
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,32 +34,3 @@ class TestConfig(unittest.TestCase):
|
||||||
BMConfigParser().safeGetInt('nonexistent', 'nonexistent'), 0)
|
BMConfigParser().safeGetInt('nonexistent', 'nonexistent'), 0)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
BMConfigParser().safeGetInt('nonexistent', 'nonexistent', 42), 42)
|
BMConfigParser().safeGetInt('nonexistent', 'nonexistent', 42), 42)
|
||||||
|
|
||||||
|
|
||||||
class TestProcessConfig(TestProcessProto):
|
|
||||||
"""A test case for keys.dat"""
|
|
||||||
home = tempfile.mkdtemp()
|
|
||||||
|
|
||||||
def test_config_defaults(self):
|
|
||||||
"""Test settings in the generated config"""
|
|
||||||
self._stop_process()
|
|
||||||
self._kill_process()
|
|
||||||
config = BMConfigParser()
|
|
||||||
config.read(os.path.join(self.home, 'keys.dat'))
|
|
||||||
|
|
||||||
self.assertEqual(config.safeGetInt(
|
|
||||||
'bitmessagesettings', 'settingsversion'), 10)
|
|
||||||
self.assertEqual(config.safeGetInt(
|
|
||||||
'bitmessagesettings', 'port'), 8444)
|
|
||||||
# don't connect
|
|
||||||
self.assertTrue(config.safeGetBoolean(
|
|
||||||
'bitmessagesettings', 'dontconnect'))
|
|
||||||
# API disabled
|
|
||||||
self.assertFalse(config.safeGetBoolean(
|
|
||||||
'bitmessagesettings', 'apienabled'))
|
|
||||||
|
|
||||||
# extralowdifficulty is false
|
|
||||||
self.assertEqual(config.safeGetInt(
|
|
||||||
'bitmessagesettings', 'defaultnoncetrialsperbyte'), 1000)
|
|
||||||
self.assertEqual(config.safeGetInt(
|
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes'), 1000)
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
"""
|
||||||
|
Various tests for config
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
|
from .test_process import TestProcessProto
|
||||||
|
|
||||||
|
|
||||||
|
class TestProcessConfig(TestProcessProto):
|
||||||
|
"""A test case for keys.dat"""
|
||||||
|
home = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_defaults(self):
|
||||||
|
"""Test settings in the generated config"""
|
||||||
|
config = BMConfigParser()
|
||||||
|
self._stop_process()
|
||||||
|
self._kill_process()
|
||||||
|
config.read(os.path.join(self.home, 'keys.dat'))
|
||||||
|
|
||||||
|
self.assertEqual(config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'settingsversion'), 10)
|
||||||
|
self.assertEqual(config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'port'), 8444)
|
||||||
|
# don't connect
|
||||||
|
self.assertTrue(config.safeGetBoolean(
|
||||||
|
'bitmessagesettings', 'dontconnect'))
|
||||||
|
# API disabled
|
||||||
|
self.assertFalse(config.safeGetBoolean(
|
||||||
|
'bitmessagesettings', 'apienabled'))
|
||||||
|
|
||||||
|
# extralowdifficulty is false
|
||||||
|
self.assertEqual(config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'defaultnoncetrialsperbyte'), 1000)
|
||||||
|
self.assertEqual(config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes'), 1000)
|
|
@ -1,73 +0,0 @@
|
||||||
"""
|
|
||||||
Test for sqlThread
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
from ..helper_sql import sqlStoredProcedure, sql_ready, sqlExecute, SqlBulkExecute, sqlQuery, sqlExecuteScript
|
|
||||||
from ..class_sqlThread import (sqlThread)
|
|
||||||
from ..addresses import encodeAddress
|
|
||||||
from .common import skip_python3
|
|
||||||
|
|
||||||
|
|
||||||
skip_python3()
|
|
||||||
|
|
||||||
|
|
||||||
class TestSqlThread(unittest.TestCase):
|
|
||||||
"""
|
|
||||||
Test case for SQLThread
|
|
||||||
"""
|
|
||||||
|
|
||||||
# query file path
|
|
||||||
root_path = os.path.dirname(os.path.dirname(__file__))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
# Start SQL thread
|
|
||||||
sqlLookup = sqlThread()
|
|
||||||
sqlLookup.daemon = False
|
|
||||||
sqlLookup.start()
|
|
||||||
sql_ready.wait()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUp(cls):
|
|
||||||
tables = list(sqlQuery("select name from sqlite_master where type is 'table'"))
|
|
||||||
with SqlBulkExecute() as sql:
|
|
||||||
for q in tables:
|
|
||||||
sql.execute("drop table if exists %s" % q)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDown(cls):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
# Stop sql thread
|
|
||||||
sqlStoredProcedure('exit')
|
|
||||||
|
|
||||||
def initialise_database(self, file):
|
|
||||||
"""
|
|
||||||
Initialise DB
|
|
||||||
"""
|
|
||||||
|
|
||||||
sql_as_string = open(os.path.join(self.root_path, "tests/sql/{}.sql".format(file))).read()
|
|
||||||
sqlExecuteScript(sql_as_string)
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_function(self):
|
|
||||||
# call create function
|
|
||||||
|
|
||||||
encoded_str = encodeAddress(4, 1, "21122112211221122112")
|
|
||||||
|
|
||||||
# Initialise Database
|
|
||||||
self.initialise_database("create_function")
|
|
||||||
|
|
||||||
sqlExecute('''INSERT INTO testhash (addressversion, hash) VALUES(4, "21122112211221122112")''')
|
|
||||||
# call function in query
|
|
||||||
|
|
||||||
sqlExecute('''UPDATE testhash SET address=(enaddr(testhash.addressversion, 1, hash)) WHERE hash=testhash.hash''')
|
|
||||||
|
|
||||||
# Assertion
|
|
||||||
query = sqlQuery('''select * from testhash;''')
|
|
||||||
self.assertEqual(query[0][-1], encoded_str, "test case fail for create_function")
|
|
||||||
sqlExecute('''DROP TABLE testhash''')
|
|
Loading…
Reference in New Issue