imported helper_addressGenerator module
This commit is contained in:
parent
7825229444
commit
07a1ce9914
|
@ -47,7 +47,7 @@ class sqlThread(threading.Thread):
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TABLE subscriptions (label text, address text, enabled bool)''')
|
'''CREATE TABLE subscriptions (label text, address text, enabled bool)''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TABLE addressbook (label text, address text, UNIQUE(address) ON CONFLICT REPLACE)''')
|
'''CREATE TABLE addressbook (label text, address text, UNIQUE(address) ON CONFLICT IGNORE)''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TABLE blacklist (label text, address text, enabled bool)''')
|
'''CREATE TABLE blacklist (label text, address text, enabled bool)''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
|
@ -388,9 +388,7 @@ class sqlThread(threading.Thread):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'In messages.dat database, done adding address field to the pubkeys table'
|
'In messages.dat database, done adding address field to the pubkeys table'
|
||||||
' and removing the hash field.')
|
' and removing the hash field.')
|
||||||
item = '''update settings set value=? WHERE key='version';'''
|
self.cur.execute('''update settings set value=10 WHERE key='version';''')
|
||||||
parameters = (10,)
|
|
||||||
self.cur.execute(item, parameters)
|
|
||||||
|
|
||||||
# Update the address colunm to unique in addressbook table
|
# Update the address colunm to unique in addressbook table
|
||||||
item = '''SELECT value FROM settings WHERE key='version';'''
|
item = '''SELECT value FROM settings WHERE key='version';'''
|
||||||
|
@ -405,9 +403,10 @@ class sqlThread(threading.Thread):
|
||||||
'''ALTER TABLE addressbook RENAME TO old_addressbook''')
|
'''ALTER TABLE addressbook RENAME TO old_addressbook''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''CREATE TABLE addressbook'''
|
'''CREATE TABLE addressbook'''
|
||||||
''' (label text, address text, UNIQUE(address) ON CONFLICT REPLACE)''')
|
''' (label text, address text, UNIQUE(address) ON CONFLICT IGNORE)''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''INSERT INTO addressbook SELECT label, address FROM old_addressbook;''')
|
'''INSERT INTO addressbook SELECT label, address FROM old_addressbook;''')
|
||||||
|
self.cur.execute('''DROP TABLE old_addressbook''')
|
||||||
self.cur.execute('''update settings set value=11 WHERE key='version';''')
|
self.cur.execute('''update settings set value=11 WHERE key='version';''')
|
||||||
|
|
||||||
# Are you hoping to add a new option to the keys.dat file of existing
|
# Are you hoping to add a new option to the keys.dat file of existing
|
||||||
|
|
|
@ -277,15 +277,7 @@ class TestCore(unittest.TestCase):
|
||||||
cleanup(files=('knownnodes.dat',))
|
cleanup(files=('knownnodes.dat',))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_random_address():
|
def delete_address_from_addressbook(address):
|
||||||
"""Generating random address"""
|
|
||||||
import queues
|
|
||||||
streamNumberForAddress = 1
|
|
||||||
queues.addressGeneratorQueue.put((
|
|
||||||
'createRandomAddress', 4, streamNumberForAddress,
|
|
||||||
"test1", 1, "", False))
|
|
||||||
|
|
||||||
def delete_address_from_database(self, address):
|
|
||||||
"""Clean up addressbook"""
|
"""Clean up addressbook"""
|
||||||
sqlQuery('''delete from addressbook where address=?''', address)
|
sqlQuery('''delete from addressbook where address=?''', address)
|
||||||
|
|
||||||
|
@ -293,22 +285,21 @@ class TestCore(unittest.TestCase):
|
||||||
"""checking same address is added twice in addressbook"""
|
"""checking same address is added twice in addressbook"""
|
||||||
self.assertTrue(helper_addressbook.insert(label='test1', address=self.addr))
|
self.assertTrue(helper_addressbook.insert(label='test1', address=self.addr))
|
||||||
self.assertFalse(helper_addressbook.insert(label='test1', address=self.addr))
|
self.assertFalse(helper_addressbook.insert(label='test1', address=self.addr))
|
||||||
self.delete_address_from_database(self.addr)
|
self.delete_address_from_addressbook(self.addr)
|
||||||
|
|
||||||
def test_is_address_present_in_addressbook(self):
|
def test_is_address_present_in_addressbook(self):
|
||||||
"""checking is address added in addressbook or not"""
|
"""checking is address added in addressbook or not"""
|
||||||
helper_addressbook.insert(label='test1', address=self.addr)
|
helper_addressbook.insert(label='test1', address=self.addr)
|
||||||
queryreturn = sqlQuery('''select count(*) from addressbook where address=?''', self.addr)
|
queryreturn = sqlQuery('''select count(*) from addressbook where address=?''', self.addr)
|
||||||
self.assertTrue(bool(queryreturn[0][0]))
|
self.assertEqual(queryreturn[0][0], 1)
|
||||||
self.delete_address_from_database(self.addr)
|
self.delete_address_from_addressbook(self.addr)
|
||||||
|
|
||||||
def test_is_own_address_add_to_addressbook(self):
|
def test_is_own_address_add_to_addressbook(self):
|
||||||
"""Checking own address adding in addressbook"""
|
"""Checking own address adding in addressbook"""
|
||||||
self.generate_random_address()
|
from helper_addressGenerator import createAddressIfNeeded
|
||||||
time.sleep(.5)
|
|
||||||
try:
|
try:
|
||||||
all_addresses = BMConfigParser().addresses()
|
address = createAddressIfNeeded('test1')
|
||||||
self.assertFalse(helper_addressbook.insert(label='test', address=all_addresses[0]))
|
self.assertFalse(helper_addressbook.insert(label='test', address=address))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self.fail("Can't generate addresses")
|
self.fail("Can't generate addresses")
|
||||||
|
|
||||||
|
@ -318,8 +309,8 @@ class TestCore(unittest.TestCase):
|
||||||
address2 = 'BM-2CvwTDuZpWf7ungdRzFTwUhwIj6XXbPIsp'
|
address2 = 'BM-2CvwTDuZpWf7ungdRzFTwUhwIj6XXbPIsp'
|
||||||
self.assertTrue(helper_addressbook.insert(label='test1', address=address1))
|
self.assertTrue(helper_addressbook.insert(label='test1', address=address1))
|
||||||
self.assertTrue(helper_addressbook.insert(label='test2', address=address2))
|
self.assertTrue(helper_addressbook.insert(label='test2', address=address2))
|
||||||
self.delete_address_from_database(address1)
|
self.delete_address_from_addressbook(address1)
|
||||||
self.delete_address_from_database(address2)
|
self.delete_address_from_addressbook(address2)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user