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
c0b4e9e4
Commit
c0b4e9e4
authored
5 years ago
by
matograine
Committed by
Moul
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[test]
#111
: Send multiple amounts
* add transaction_amount() unittest
parent
abb39ce8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_unit_tx.py
+83
-1
83 additions, 1 deletion
tests/test_unit_tx.py
with
83 additions
and
1 deletion
tests/test_unit_tx.py
+
83
−
1
View file @
c0b4e9e4
import
pytest
from
silkaj.tx
import
truncBase
,
transaction_confirmation
from
silkaj.tx
import
truncBase
,
transaction_confirmation
,
transaction_amount
from
silkaj.tui
import
display_pubkey
,
display_amount
from
silkaj.money
import
UDValue
from
silkaj.constants
import
G1_SYMBOL
...
...
@@ -184,3 +184,85 @@ async def test_transaction_confirmation(
comment
,
)
assert
tx
==
expected
# transaction_amount()
@pytest.mark.parametrize
(
"
amount, amountUD, outputAddresses, expected
"
,
[
(
"
10
"
,
None
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
],
([
1000
],
1000
)),
(
"
10:2.367
"
,
None
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
,
"
4szFkvQ5tzzhwcfUtZD32hdoG2ZzhvG3ZtfR61yjnxdw
"
,
],
([
1000
,
237
],
1237
),
),
(
"
10
"
,
None
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
,
"
4szFkvQ5tzzhwcfUtZD32hdoG2ZzhvG3ZtfR61yjnxdw
"
,
],
([
1000
],
2000
),
),
(
None
,
"
1.263
"
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
],
([
397
],
397
)),
(
None
,
"
0.5:10
"
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
,
"
4szFkvQ5tzzhwcfUtZD32hdoG2ZzhvG3ZtfR61yjnxdw
"
,
],
([
157
,
3140
],
3297
),
),
(
None
,
"
0.5
"
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
,
"
4szFkvQ5tzzhwcfUtZD32hdoG2ZzhvG3ZtfR61yjnxdw
"
,
],
([
157
],
314
),
),
(
"
10:56
"
,
None
,
[
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
],
"
Error : The number of passed recipients (--output) is not the same as the passed amounts (--amount).
"
,
),
(
None
,
"
1:45
"
,
"
DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw
"
,
"
Error : The number of passed recipients (--output) is not the same as the passed amounts (--amount).
"
,
),
],
)
@pytest.mark.asyncio
async
def
test_transaction_amount
(
amount
,
amountUD
,
outputAddresses
,
expected
,
capsys
,
monkeypatch
):
# patched functions
monkeypatch
.
setattr
(
"
silkaj.money.UDValue.get_ud_value
"
,
patched
.
ud_value
)
if
amount
:
amount_given
=
amount
if
amountUD
:
amount_given
=
amountUD
# test errors
if
len
(
amount_given
.
split
(
"
:
"
))
!=
1
and
len
(
outputAddresses
)
!=
len
(
amount_given
.
split
(
"
:
"
)
):
# check program exit on error
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
# read output to check error.
await
transaction_amount
(
amount
,
amountUD
,
outputAddresses
)
assert
expected
==
capsys
.
readouterr
()
assert
pytest_exit
.
type
==
SystemExit
# test good values
else
:
assert
expected
==
await
transaction_amount
(
amount
,
amountUD
,
outputAddresses
)
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