Skip to content

Commit 287f380

Browse files
authored
Merge pull request #1190 from mkoura/ttl_far_future_expected
TTL far in the future behavior is expected
2 parents b95af51 + 3cdfe53 commit 287f380

File tree

1 file changed

+44
-60
lines changed

1 file changed

+44
-60
lines changed

cardano_node_tests/tests/test_transactions.py

+44-60
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,50 @@ def test_utxo_with_datum_hash(
844844
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_1)
845845
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_2)
846846

847+
@allure.link(helpers.get_vcs_link())
848+
@pytest.mark.dbsync
849+
def test_far_future_ttl(
850+
self,
851+
cluster: clusterlib.ClusterLib,
852+
payment_addrs: List[clusterlib.AddressRecord],
853+
):
854+
"""Send a transaction with ttl far in the future."""
855+
temp_template = common.get_test_id(cluster)
856+
857+
src_addr = payment_addrs[0]
858+
dst_addr = payment_addrs[1]
859+
860+
tx_files = clusterlib.TxFiles(signing_key_files=[src_addr.skey_file])
861+
destinations = [clusterlib.TxOut(address=dst_addr.address, amount=2_000_000)]
862+
863+
ttl = cluster.get_slot_no() + 10_000_000
864+
fee = cluster.calculate_tx_fee(
865+
src_address=src_addr.address,
866+
tx_name=temp_template,
867+
txouts=destinations,
868+
tx_files=tx_files,
869+
invalid_hereafter=ttl,
870+
)
871+
872+
tx_raw_output = cluster.build_raw_tx(
873+
src_address=src_addr.address,
874+
tx_name=temp_template,
875+
txouts=destinations,
876+
tx_files=tx_files,
877+
fee=fee,
878+
invalid_hereafter=ttl,
879+
)
880+
out_file_signed = cluster.sign_tx(
881+
tx_body_file=tx_raw_output.out_file,
882+
signing_key_files=tx_files.signing_key_files,
883+
tx_name=temp_template,
884+
)
885+
886+
# it should be possible to submit a transaction with ttl far in the future
887+
cluster.submit_tx(out_file_signed, txins=tx_raw_output.txins)
888+
889+
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output)
890+
847891

848892
@pytest.mark.testnets
849893
@pytest.mark.smoke
@@ -2088,66 +2132,6 @@ def test_past_ttl(
20882132
exc_val = str(excinfo.value)
20892133
assert "ExpiredUTxO" in exc_val or "ValidityIntervalUTxO" in exc_val
20902134

2091-
@allure.link(helpers.get_vcs_link())
2092-
def test_far_future_ttl(
2093-
self,
2094-
cluster: clusterlib.ClusterLib,
2095-
pool_users: List[clusterlib.PoolUser],
2096-
):
2097-
"""Try to send a transaction with ttl too far in the future.
2098-
2099-
Too far means slot further away than current slot + 3k/f slot.
2100-
2101-
Expect failure.
2102-
"""
2103-
temp_template = common.get_test_id(cluster)
2104-
2105-
src_address = pool_users[0].payment.address
2106-
dst_address = pool_users[1].payment.address
2107-
2108-
tx_files = clusterlib.TxFiles(signing_key_files=[pool_users[0].payment.skey_file])
2109-
destinations = [clusterlib.TxOut(address=dst_address, amount=2_000_000)]
2110-
2111-
# ttl can't be further than 3k/f slot
2112-
furthest_slot = round(
2113-
3 * cluster.genesis["securityParam"] / cluster.genesis["activeSlotsCoeff"]
2114-
)
2115-
2116-
ttl = cluster.get_slot_no() + furthest_slot + 100_000
2117-
fee = cluster.calculate_tx_fee(
2118-
src_address=src_address,
2119-
tx_name=temp_template,
2120-
txouts=destinations,
2121-
tx_files=tx_files,
2122-
invalid_hereafter=ttl,
2123-
)
2124-
2125-
tx_raw_output = cluster.build_raw_tx(
2126-
src_address=src_address,
2127-
tx_name=temp_template,
2128-
txouts=destinations,
2129-
tx_files=tx_files,
2130-
fee=fee,
2131-
invalid_hereafter=ttl,
2132-
)
2133-
out_file_signed = cluster.sign_tx(
2134-
tx_body_file=tx_raw_output.out_file,
2135-
signing_key_files=tx_files.signing_key_files,
2136-
tx_name=temp_template,
2137-
)
2138-
2139-
# it should NOT be possible to submit a transaction with ttl far in the future
2140-
err_str = ""
2141-
try:
2142-
cluster.submit_tx(out_file_signed, txins=tx_raw_output.txins)
2143-
except clusterlib.CLIError as err:
2144-
err_str = str(err)
2145-
2146-
if not err_str:
2147-
pytest.xfail("TTL too far in future is not rejected")
2148-
2149-
assert "ValidityIntervalUTxO" in err_str
2150-
21512135
@allure.link(helpers.get_vcs_link())
21522136
def test_duplicated_tx(
21532137
self,

0 commit comments

Comments
 (0)