diff --git a/silkaj/tx.py b/silkaj/tx.py index 8b0d75af7477a3d51963658d88d3b3224c3999c3..0b1c9267e7df43fe61f6da4d00f5fd7489961616 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -222,6 +222,11 @@ def check_transaction_values( Check the balance is big enough for the transaction """ 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): if ct.check_pubkey_format(outputAddress): outputAddresses[i] = ct.validate_checksum(outputAddress) diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index 1240ab9f892e1dc46d39f0e7d2551c223a6249cf..2d9dfd4b01f20d2f54565ce3c84234591da88fbe 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -1257,6 +1257,17 @@ async def test_generate_and_send_transaction( "A", "HcRgKh4LwbQVYuAc3xAdCynYXpKoiPE6qdxCMa8JeHat", ), + ( + "Test", + [ + "DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw", + ] + * 92, + "", + False, + "A", + "", + ), ], ) def test_check_transaction_values( @@ -1335,6 +1346,16 @@ def test_check_transaction_values( False, "A", ), + ( + "Test", + [ + "DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw", + ] + * 93, + "", + False, + "A", + ), ], ) def test_check_transaction_values_errors( @@ -1345,6 +1366,8 @@ def test_check_transaction_values_errors( comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey ) 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: assert display == "Error: the format of the comment is invalid" elif len(comment) > tx.MAX_COMMENT_LENGTH: