Skip to content

Commit

Permalink
test: Write v2 security tests for token create operation (#12952)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Michael Tinker <[email protected]>
Signed-off-by: Fatmagyul Chitakova <[email protected]>
Co-authored-by: Ivo Yankov <[email protected]>
Co-authored-by: Michael Tinker <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent be3008a commit 75990ed
Show file tree
Hide file tree
Showing 4 changed files with 760 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING;
import static com.hedera.hapi.node.base.ResponseCodeEnum.MEMO_TOO_LONG;
import static com.hedera.node.app.spi.key.KeyUtils.isValid;
import static com.hedera.node.app.spi.validation.ExpiryMeta.NA;
import static com.hedera.node.app.spi.workflows.HandleException.validateTrue;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -91,7 +92,8 @@ public void validateExpiry(long expiry) {
context.configuration().getConfigData(EntitiesConfig.class).maxLifetime();
final var now = context.consensusNow().getEpochSecond();
final var expiryGivenMaxLifetime = now + maxEntityLifetime;
validateTrue(expiry > now && expiry < expiryGivenMaxLifetime, INVALID_EXPIRATION_TIME);
final var impliedExpiry = expiry == NA ? expiryGivenMaxLifetime : expiry;
validateTrue(impliedExpiry > now && impliedExpiry <= expiryGivenMaxLifetime, INVALID_EXPIRATION_TIME);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.hedera.hapi.node.base.ResponseCodeEnum.INSUFFICIENT_TX_FEE;
import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_ACCOUNT_ID;
import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_EXPIRATION_TIME;
import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_TRANSACTION_BODY;
import static com.hedera.hapi.node.base.ResponseCodeEnum.MISSING_TOKEN_SYMBOL;
import static com.hedera.hapi.node.base.ResponseCodeEnum.OK;
Expand Down Expand Up @@ -180,9 +179,6 @@ private ResponseCodeEnum validityOfSynth(@NonNull final TokenCreateTransactionBo
if (treasuryAccount == null) {
return INVALID_ACCOUNT_ID;
}
if (op.autoRenewAccount() == null) {
return INVALID_EXPIRATION_TIME;
}
return OK;
}

Expand Down
Loading

0 comments on commit 75990ed

Please sign in to comment.