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

[feat] #281 : modify check_transaction_values() to check the number of outputs.

  * add case inrelated tests
parent 83f2a0c8
No related branches found
No related tags found
No related merge requests found
...@@ -222,6 +222,11 @@ def check_transaction_values( ...@@ -222,6 +222,11 @@ def check_transaction_values(
Check the balance is big enough for the transaction Check the balance is big enough for the transaction
""" """
checkComment(comment) checkComment(comment)
# we check output numbers and leave one line for the backchange.
if len(outputAddresses) > (MAX_OUTPUTS - 1):
tools.message_exit(
"Error : there should be less than {0} outputs.".format(MAX_OUTPUTS - 1)
)
for i, outputAddress in enumerate(outputAddresses): for i, outputAddress in enumerate(outputAddresses):
if ct.check_pubkey_format(outputAddress): if ct.check_pubkey_format(outputAddress):
outputAddresses[i] = ct.validate_checksum(outputAddress) outputAddresses[i] = ct.validate_checksum(outputAddress)
......
...@@ -1257,6 +1257,17 @@ async def test_generate_and_send_transaction( ...@@ -1257,6 +1257,17 @@ async def test_generate_and_send_transaction(
"A", "A",
"HcRgKh4LwbQVYuAc3xAdCynYXpKoiPE6qdxCMa8JeHat", "HcRgKh4LwbQVYuAc3xAdCynYXpKoiPE6qdxCMa8JeHat",
), ),
(
"Test",
[
"DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw",
]
* 92,
"",
False,
"A",
"",
),
], ],
) )
def test_check_transaction_values( def test_check_transaction_values(
...@@ -1335,6 +1346,16 @@ def test_check_transaction_values( ...@@ -1335,6 +1346,16 @@ def test_check_transaction_values(
False, False,
"A", "A",
), ),
(
"Test",
[
"DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw",
]
* 93,
"",
False,
"A",
),
], ],
) )
def test_check_transaction_values_errors( def test_check_transaction_values_errors(
...@@ -1345,6 +1366,8 @@ def test_check_transaction_values_errors( ...@@ -1345,6 +1366,8 @@ def test_check_transaction_values_errors(
comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey
) )
display = capsys.readouterr() display = capsys.readouterr()
if len(outputAddresses) > (tx.MAX_OUTPUTS - 1):
assert display == "Error : there should be less than 92 outputs."
if comment.find("Wrong_Char_") != -1: if comment.find("Wrong_Char_") != -1:
assert display == "Error: the format of the comment is invalid" assert display == "Error: the format of the comment is invalid"
elif len(comment) > tx.MAX_COMMENT_LENGTH: elif len(comment) > tx.MAX_COMMENT_LENGTH:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment