Add enaddr sqlite function for encoding a bitmessage address #1740

Closed
cis-muzahid wants to merge 1 commits from db_functions into v0.6
cis-muzahid commented 2021-03-06 15:36:34 +01:00 (Migrated from github.com)

Add enaddr sqlite function so that this operation (encoding addresses) can be performed inside sql statements.

Add `enaddr` sqlite function so that this operation (encoding addresses) can be performed inside sql statements.
PeterSurda (Migrated from github.com) requested changes 2021-03-07 13:21:26 +01:00
PeterSurda (Migrated from github.com) left a comment
  • test direct updates, without SELECT
  • make exception more specific and if needed, split it into 2, one for old python, one for old sqlite
  • make the creation of custom function a separate method. This way you can also simplify setup and don't need to start the thread in the test. It would be a more tight unit test.
  • use and check an actual address rather than just if it puts a record into the database.
- [x] test direct updates, without `SELECT` - [x] make exception more specific and if needed, split it into 2, one for old python, one for old sqlite - [x] make the creation of custom function a separate method. This way you can also simplify setup and don't need to start the thread in the test. It would be a more tight unit test. - [x] use and check an actual address rather than just if it puts a record into the database.
PeterSurda (Migrated from github.com) commented 2021-03-06 17:03:50 +01:00

how about
UPDATE pubkeys SET address=enaddr(addressversion, 1, hash)
that doesn't work? I don't know, haven't tried it.

how about `UPDATE pubkeys SET address=enaddr(addressversion, 1, hash)` that doesn't work? I don't know, haven't tried it.
PeterSurda (Migrated from github.com) commented 2021-03-06 17:11:07 +01:00

This should be a more specific exception or actually two. One for old python, one for old sqlite.

This should be a more specific exception or actually two. One for old python, one for old sqlite.
PeterSurda (Migrated from github.com) commented 2021-03-06 17:06:27 +01:00

bad docstring

bad docstring
PeterSurda (Migrated from github.com) reviewed 2021-03-08 08:56:03 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-08 08:56:03 +01:00

sqlite.NotSupportedError for old sqlite, TypeError for old python

`sqlite.NotSupportedError` for old sqlite, `TypeError` for old python
PeterSurda (Migrated from github.com) reviewed 2021-03-10 09:27:19 +01:00
@ -0,0 +26,4 @@
# Start SQL thread
sqlLookup = sqlThread()
sqlLookup.daemon = False
sqlLookup.start()
PeterSurda (Migrated from github.com) commented 2021-03-10 09:27:19 +01:00

add sql_ready.wait()

add `sql_ready.wait()`
PeterSurda (Migrated from github.com) reviewed 2021-03-10 09:27:32 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-10 09:27:32 +01:00

als import sql_ready

als import `sql_ready`
PeterSurda (Migrated from github.com) requested changes 2021-03-10 14:28:33 +01:00
PeterSurda (Migrated from github.com) left a comment

test direct updates and do the other things I mentioned.

test direct updates and do the other things I mentioned.
PeterSurda (Migrated from github.com) commented 2021-03-10 14:26:13 +01:00

this should be a separate method/function, either in helper_sql or elsewhere in this file.

this should be a separate method/function, either in `helper_sql` or elsewhere in this file.
PeterSurda (Migrated from github.com) commented 2021-03-10 14:23:24 +01:00

test content validity, not just if an entry exists.

test content validity, not just if an entry exists.
PeterSurda (Migrated from github.com) commented 2021-03-10 14:24:16 +01:00

here also the two exceptions like in class_sqlThread

here also the two exceptions like in `class_sqlThread`
PeterSurda (Migrated from github.com) commented 2021-03-10 14:25:37 +01:00

this should be cleaned up so that an exception can simply be ignored and treated as a failure by the test suite

this should be cleaned up so that an exception can simply be ignored and treated as a failure by the test suite
@ -0,0 +54,4 @@
sqlExecuteScript(sql_as_string)
def test_create_function(self):
PeterSurda (Migrated from github.com) commented 2021-03-10 14:25:06 +01:00

there should be a separate method for creating, and it should be either in helper_sql or in class_sqlThread. Here it should only test whether it works, not create the function again

there should be a separate method for creating, and it should be either in `helper_sql` or in `class_sqlThread`. Here it should only test whether it works, not create the function again
PeterSurda (Migrated from github.com) reviewed 2021-03-11 15:41:42 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-11 15:41:42 +01:00

docstring missing

docstring missing
PeterSurda (Migrated from github.com) reviewed 2021-03-11 15:43:07 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-11 15:43:07 +01:00

I don't think this is necessary as it's created by the sql thread already.

I don't think this is necessary as it's created by the sql thread already.
PeterSurda (Migrated from github.com) reviewed 2021-03-11 15:44:08 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-11 15:44:08 +01:00

these should be class variables or constants defined elsewhere.

Also version should be 4.

these should be class variables or constants defined elsewhere. Also version should be 4.
PeterSurda (Migrated from github.com) reviewed 2021-03-11 15:44:29 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-11 15:44:28 +01:00

addressversion should be 4

addressversion should be 4
PeterSurda (Migrated from github.com) reviewed 2021-03-11 15:45:40 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-11 15:45:40 +01:00

Also I think this would be better inside class_sqlThread. This function doesn't need to be called from other places.

Also I think this would be better inside `class_sqlThread`. This function doesn't need to be called from other places.
PeterSurda (Migrated from github.com) requested changes 2021-03-11 15:45:58 +01:00
PeterSurda (Migrated from github.com) left a comment

please make the requested changes

please make the requested changes
PeterSurda (Migrated from github.com) requested changes 2021-03-14 18:23:11 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-14 18:16:45 +01:00

The function is created only when upgrading from version 9 to version 10. This is probably why the tests raise an exception. It should be created always. Perhaps right after creating the cursor.

The function is created only when upgrading from version 9 to version 10. This is probably why the tests raise an exception. It should be created always. Perhaps right after creating the cursor.
PeterSurda (Migrated from github.com) commented 2021-03-14 18:22:25 +01:00

This section should also be a separate method inside the class

This section should also be a separate method inside the class
PeterSurda (Migrated from github.com) commented 2021-03-14 18:10:05 +01:00

sqlExecute('''DROP TABLE testhash''')

`sqlExecute('''DROP TABLE testhash''')`
PeterSurda (Migrated from github.com) commented 2021-03-14 18:10:19 +01:00

remove ;

remove `;`
PeterSurda (Migrated from github.com) commented 2021-03-14 18:10:36 +01:00

remove ;

remove `;`
PeterSurda (Migrated from github.com) commented 2021-03-14 18:10:44 +01:00

remove ;

remove `;`
PeterSurda (Migrated from github.com) commented 2021-03-14 18:11:00 +01:00

Remove lines 20-22.

Remove lines 20-22.
PeterSurda (Migrated from github.com) commented 2021-03-14 18:18:08 +01:00

I'm not sure this (line 81) actually tests anything. Remove.

I'm not sure this (line 81) actually tests anything. Remove.
PeterSurda (Migrated from github.com) reviewed 2021-03-15 12:15:51 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-15 12:15:51 +01:00

remove these lines

remove these lines
PeterSurda (Migrated from github.com) reviewed 2021-03-15 12:16:32 +01:00
@ -358,16 +362,11 @@ class sqlThread(threading.Thread):
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
# table. Then we can take out the hash field.
PeterSurda (Migrated from github.com) commented 2021-03-15 12:16:32 +01:00

direct update, not joined.

direct update, not joined.
PeterSurda (Migrated from github.com) reviewed 2021-03-15 12:17:46 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-15 12:17:46 +01:00

direct update, not join

direct update, not join
PeterSurda (Migrated from github.com) reviewed 2021-03-15 12:20:06 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-15 12:20:06 +01:00

I think this isn't correct, as xenial returns this:
2021-03-15 11:28:56,156 - ERROR - Got error while pass deterministic in sqlite create function function takes at most 3 arguments (4 given), Passing 3 params

I think this isn't correct, as xenial returns this: `2021-03-15 11:28:56,156 - ERROR - Got error while pass deterministic in sqlite create function function takes at most 3 arguments (4 given), Passing 3 params`
PeterSurda commented 2021-03-15 12:20:41 +01:00 (Migrated from github.com)

Also fix python3 tests (skip).

Also fix python3 tests (skip).
PeterSurda (Migrated from github.com) reviewed 2021-03-15 15:19:47 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-15 15:19:47 +01:00

My bad. Just downgrade the log to debug severity.

My bad. Just downgrade the log to debug severity.
PeterSurda (Migrated from github.com) requested changes 2021-03-15 16:20:06 +01:00
PeterSurda (Migrated from github.com) commented 2021-03-15 16:19:59 +01:00

downgrade to logger.debug

downgrade to `logger.debug`
PeterSurda (Migrated from github.com) commented 2021-03-15 16:19:31 +01:00

this should say # python3

this should say `# python3`
PeterSurda (Migrated from github.com) commented 2021-03-15 16:19:42 +01:00

# python2

`# python2`
PeterSurda (Migrated from github.com) approved these changes 2021-03-15 16:39:55 +01:00
PeterSurda (Migrated from github.com) left a comment

I approve, just the python3 compatibility needs to be fixed in class_sqlThread.py and bmconfigparser.py in a separate PR before this can be merged.

I approve, just the python3 compatibility needs to be fixed in `class_sqlThread.py` and `bmconfigparser.py` in a separate PR before this can be merged.
PeterSurda commented 2021-04-28 10:16:03 +02:00 (Migrated from github.com)

@cis-muzahid Please confirm this is obsolete.

@cis-muzahid Please confirm this is obsolete.
g1itch commented 2021-05-28 15:10:41 +02:00 (Migrated from github.com)

This duplicates merged #1751

This duplicates merged #1751
This repo is archived. You cannot comment on pull requests.
No description provided.