Skip to content

Commit

Permalink
chore(timelock): fix environment-based timelock check for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drcpu-github committed Jan 29, 2025
1 parent 89cdb8f commit 6d68ec7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
20 changes: 11 additions & 9 deletions data_structures/src/transaction_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,18 @@ pub fn transaction_inputs_sum(
// Verify that commits are only accepted after the time lock expired
let (epoch_timestamp, _) = epoch_constants.epoch_timestamp(epoch)?;
let vt_time_lock = i64::try_from(vt_output.time_lock)?;
if (get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 22_000
&& vt_time_lock > epoch_timestamp
{
return Err(TransactionError::TimeLock {
expected: vt_time_lock,
current: epoch_timestamp,
if vt_time_lock > epoch_timestamp {
if get_environment() == Environment::Mainnet
|| ((get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 22_000)
{
return Err(TransactionError::TimeLock {
expected: vt_time_lock,
current: epoch_timestamp,
}
.into());
}
.into());
} else {
if !seen_output_pointers.insert(input.output_pointer()) {
// If the set already contained this output pointer
Expand Down
9 changes: 5 additions & 4 deletions validations/src/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,11 +1498,12 @@ pub fn validate_unstake_transaction<'a>(

// TODO: modify this to enable delegated staking with multiple withdrawer addresses on a single validator
// TODO: remove this check for mainnet release
if (get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 22_000
let nonce = stake_entry.first().map(|stake| stake.value.nonce).unwrap();
if get_environment() == Environment::Mainnet
|| ((get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 22_000)
{
let nonce = stake_entry.first().map(|stake| stake.value.nonce).unwrap();
if ut_tx.body.nonce != nonce {
return Err(TransactionError::UnstakeInvalidNonce {
used: ut_tx.body.nonce,
Expand Down

0 comments on commit 6d68ec7

Please sign in to comment.