Skip to content

Commit

Permalink
Fix time range on testnets
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoura committed Sep 16, 2021
1 parent b5d4ed6 commit a1b19a8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cardano_node_tests/tests/test_smart_contracts.py
Expand Up @@ -1473,11 +1473,13 @@ def test_time_range_minting(
)

slot_step2 = cluster.get_slot_no()
slots_offset = 1000
timestamp_offset_ms = int(slots_offset * cluster.slot_length + 5) * 1000

protocol_version = cluster.get_protocol_params()["protocolVersion"]["major"]
if protocol_version > 5:
# POSIX timestamp 300 sec in the future
redeemer_value = int(datetime.datetime.now().timestamp() * 1000) + 300000
# POSIX timestamp + offset
redeemer_value = int(datetime.datetime.now().timestamp() * 1000) + timestamp_offset_ms
else:
# BUG: https://github.com/input-output-hk/cardano-node/issues/3090
redeemer_value = 1000000000000
Expand Down Expand Up @@ -1509,8 +1511,8 @@ def test_time_range_minting(
tx_files=tx_files_step2,
fee=fee_step2,
plutus_mint=plutus_mint_data,
invalid_before=slot_step2 - 1000,
invalid_hereafter=slot_step2 + 1000,
invalid_before=slot_step2 - slots_offset,
invalid_hereafter=slot_step2 + slots_offset,
mint=mint,
)
tx_signed_step2 = cluster.sign_tx(
Expand Down Expand Up @@ -2207,11 +2209,13 @@ def test_time_range_minting(
)

slot_step2 = cluster.get_slot_no()
slots_offset = 1000
timestamp_offset_ms = int(slots_offset * cluster.slot_length + 5) * 1000

protocol_version = cluster.get_protocol_params()["protocolVersion"]["major"]
if protocol_version > 5:
# POSIX timestamp 300 sec in the future
redeemer_value = int(datetime.datetime.now().timestamp() * 1000) + 300000
# POSIX timestamp + offset
redeemer_value = int(datetime.datetime.now().timestamp() * 1000) + timestamp_offset_ms
else:
# BUG: https://github.com/input-output-hk/cardano-node/issues/3090
redeemer_value = 1000000000000
Expand Down Expand Up @@ -2242,8 +2246,8 @@ def test_time_range_minting(
txouts=txouts_step2,
tx_files=tx_files_step2,
plutus_mint=plutus_mint_data,
invalid_before=slot_step2 - 1000,
invalid_hereafter=slot_step2 + 1000,
invalid_before=slot_step2 - slots_offset,
invalid_hereafter=slot_step2 + slots_offset,
mint=mint,
)
tx_signed_step2 = cluster.sign_tx(
Expand Down

0 comments on commit a1b19a8

Please sign in to comment.