Skip to content

Commit 7d9a6af

Browse files
committed
Property based testing for potential inputs
1 parent 366cb87 commit 7d9a6af

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

test/pycardano/test_txbuilder.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
from dataclasses import replace
23
from test.pycardano.test_key import SK
34
from test.pycardano.util import chain_context
@@ -129,30 +130,24 @@ def test_tx_builder_with_potential_inputs(chain_context):
129130

130131
utxos = chain_context.utxos(sender)
131132

132-
tx_builder.potential_inputs.append(utxos[1])
133+
tx_builder.potential_inputs.extend(utxos)
133134

134-
tx_builder.add_output(TransactionOutput.from_primitive([sender, 500000]))
135+
for i in range(20):
136+
utxo = copy.deepcopy(utxos[0])
137+
utxo.input.index = i + 100
138+
tx_builder.potential_inputs.append(utxo)
135139

136-
tx_body = tx_builder.build(change_address=sender_address)
140+
assert len(tx_builder.potential_inputs) > 1
137141

138-
expected = {
139-
0: [[b"22222222222222222222222222222222", 1]],
140-
1: [
141-
# First output
142-
[sender_address.to_primitive(), 500000],
143-
# Second output as change
144-
[
145-
sender_address.to_primitive(),
146-
[
147-
5332431,
148-
{b"1111111111111111111111111111": {b"Token1": 1, b"Token2": 2}},
149-
],
150-
],
151-
],
152-
2: 167569,
153-
}
142+
tx_builder.add_output(
143+
TransactionOutput.from_primitive(
144+
[sender, [5000000, {b"1111111111111111111111111111": {b"Token1": 1}}]]
145+
)
146+
)
154147

155-
assert expected == tx_body.to_primitive()
148+
tx_body = tx_builder.build(change_address=sender_address)
149+
150+
assert len(tx_body.inputs) < len(tx_builder.potential_inputs)
156151

157152

158153
def test_tx_builder_multi_asset(chain_context):

0 commit comments

Comments
 (0)