Skip to content
Snippets Groups Projects
Commit 9edc0d2e authored by matograine's avatar matograine
Browse files

[mod] tx.py : use MAX_COMMENT_LENGTH as a constant for comment check

parent d0929b13
No related branches found
No related tags found
1 merge request!130#213: Write unit tests for the transaction command
...@@ -41,6 +41,8 @@ from duniterpy.api.bma.tx import process ...@@ -41,6 +41,8 @@ from duniterpy.api.bma.tx import process
from duniterpy.documents import BlockUID, Transaction from duniterpy.documents import BlockUID, Transaction
from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
MAX_COMMENT_LENGTH = 255
@command("tx", help="Send transaction") @command("tx", help="Send transaction")
@option( @option(
...@@ -469,13 +471,13 @@ def generate_output(listoutput, unitbase, rest, recipient_address): ...@@ -469,13 +471,13 @@ def generate_output(listoutput, unitbase, rest, recipient_address):
unitbase = unitbase - 1 unitbase = unitbase - 1
def checkComment(Comment): def checkComment(comment):
if len(Comment) > 255: if len(comment) > MAX_COMMENT_LENGTH:
tools.message_exit("Error: Comment is too long") tools.message_exit("Error: Comment is too long")
regex = compile( regex = compile(
"^[0-9a-zA-Z\\ \\-\\_\\:\\/\\;\\*\\[\\]\\(\\)\\?\\!\\^\\+\\=\\@\\&\\~\\#\\{\\}\\|\\\\<\\>\\%\\.]*$" "^[0-9a-zA-Z\\ \\-\\_\\:\\/\\;\\*\\[\\]\\(\\)\\?\\!\\^\\+\\=\\@\\&\\~\\#\\{\\}\\|\\\\<\\>\\%\\.]*$"
) )
if not search(regex, Comment): if not search(regex, comment):
tools.message_exit("Error: the format of the comment is invalid") tools.message_exit("Error: the format of the comment is invalid")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment