Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
aeddf42e
Commit
aeddf42e
authored
5 years ago
by
matograine
Browse files
Options
Downloads
Patches
Plain Diff
[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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/tx.py
+5
-0
5 additions, 0 deletions
silkaj/tx.py
tests/test_unit_tx.py
+23
-0
23 additions, 0 deletions
tests/test_unit_tx.py
with
28 additions
and
0 deletions
silkaj/tx.py
+
5
−
0
View file @
aeddf42e
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_unit_tx.py
+
23
−
0
View file @
aeddf42e
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment