Skip to content

TTL far in the future behavior is expected #1190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 44 additions & 60 deletions cardano_node_tests/tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,50 @@ def test_utxo_with_datum_hash(
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_1)
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_2)

@allure.link(helpers.get_vcs_link())
@pytest.mark.dbsync
def test_far_future_ttl(
self,
cluster: clusterlib.ClusterLib,
payment_addrs: List[clusterlib.AddressRecord],
):
"""Send a transaction with ttl far in the future."""
temp_template = common.get_test_id(cluster)

src_addr = payment_addrs[0]
dst_addr = payment_addrs[1]

tx_files = clusterlib.TxFiles(signing_key_files=[src_addr.skey_file])
destinations = [clusterlib.TxOut(address=dst_addr.address, amount=2_000_000)]

ttl = cluster.get_slot_no() + 10_000_000
fee = cluster.calculate_tx_fee(
src_address=src_addr.address,
tx_name=temp_template,
txouts=destinations,
tx_files=tx_files,
invalid_hereafter=ttl,
)

tx_raw_output = cluster.build_raw_tx(
src_address=src_addr.address,
tx_name=temp_template,
txouts=destinations,
tx_files=tx_files,
fee=fee,
invalid_hereafter=ttl,
)
out_file_signed = cluster.sign_tx(
tx_body_file=tx_raw_output.out_file,
signing_key_files=tx_files.signing_key_files,
tx_name=temp_template,
)

# it should be possible to submit a transaction with ttl far in the future
cluster.submit_tx(out_file_signed, txins=tx_raw_output.txins)

dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output)


@pytest.mark.testnets
@pytest.mark.smoke
Expand Down Expand Up @@ -2088,66 +2132,6 @@ def test_past_ttl(
exc_val = str(excinfo.value)
assert "ExpiredUTxO" in exc_val or "ValidityIntervalUTxO" in exc_val

@allure.link(helpers.get_vcs_link())
def test_far_future_ttl(
self,
cluster: clusterlib.ClusterLib,
pool_users: List[clusterlib.PoolUser],
):
"""Try to send a transaction with ttl too far in the future.

Too far means slot further away than current slot + 3k/f slot.

Expect failure.
"""
temp_template = common.get_test_id(cluster)

src_address = pool_users[0].payment.address
dst_address = pool_users[1].payment.address

tx_files = clusterlib.TxFiles(signing_key_files=[pool_users[0].payment.skey_file])
destinations = [clusterlib.TxOut(address=dst_address, amount=2_000_000)]

# ttl can't be further than 3k/f slot
furthest_slot = round(
3 * cluster.genesis["securityParam"] / cluster.genesis["activeSlotsCoeff"]
)

ttl = cluster.get_slot_no() + furthest_slot + 100_000
fee = cluster.calculate_tx_fee(
src_address=src_address,
tx_name=temp_template,
txouts=destinations,
tx_files=tx_files,
invalid_hereafter=ttl,
)

tx_raw_output = cluster.build_raw_tx(
src_address=src_address,
tx_name=temp_template,
txouts=destinations,
tx_files=tx_files,
fee=fee,
invalid_hereafter=ttl,
)
out_file_signed = cluster.sign_tx(
tx_body_file=tx_raw_output.out_file,
signing_key_files=tx_files.signing_key_files,
tx_name=temp_template,
)

# it should NOT be possible to submit a transaction with ttl far in the future
err_str = ""
try:
cluster.submit_tx(out_file_signed, txins=tx_raw_output.txins)
except clusterlib.CLIError as err:
err_str = str(err)

if not err_str:
pytest.xfail("TTL too far in future is not rejected")

assert "ValidityIntervalUTxO" in err_str

@allure.link(helpers.get_vcs_link())
def test_duplicated_tx(
self,
Expand Down