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

[test] #213: create test for generate_output()

tests:
    * one amount in base 0 -> 1 output
    * one amount in base 2 -> 3 outputs of base 2, 1, 0
    * one listinput to be extended with the amount.
parent d612b73b
No related branches found
No related tags found
1 merge request!130#213: Write unit tests for the transaction command
Pipeline #10407 passed
......@@ -1398,3 +1398,76 @@ def test_check_transaction_values_errors(
)
def test_generate_unlocks(listinput, expected):
assert expected == tx.generate_unlocks(listinput)
# test generate_output
@pytest.mark.parametrize(
"listoutput, unitbase, rest, recipient_address, expected",
[
(
[],
0,
500,
"2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY",
[
OutputSource(
amount="500",
base=0,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
)
],
),
(
[],
2,
314,
"2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY",
[
OutputSource(
amount="3",
base=2,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
),
OutputSource(
amount="1",
base=1,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
),
OutputSource(
amount="4",
base=0,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
),
],
),
(
[
OutputSource(
amount="100",
base=0,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
)
],
0,
500,
"2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY",
[
OutputSource(
amount="100",
base=0,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
),
OutputSource(
amount="500",
base=0,
condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)",
),
],
),
],
)
def test_generate_output(listoutput, unitbase, rest, recipient_address, expected):
tx.generate_output(listoutput, unitbase, rest, recipient_address)
assert len(expected) == len(listoutput)
for e, o in zip(expected, listoutput):
assert e == o
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