Skip to content

Commit

Permalink
add security v2 model mint tests to the concurrentSuites class
Browse files Browse the repository at this point in the history
Signed-off-by: Anastasia Kovaliova <[email protected]>
  • Loading branch information
anastasiya-kovaliova committed Feb 22, 2024
1 parent 1575352 commit bb0cc01
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
5 changes: 3 additions & 2 deletions hedera-node/test-clients/src/itest/java/ConcurrentSuites.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.hedera.services.bdd.suites.contract.precompile.ContractHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractKeysHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractMintHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractMintHTSV2SecurityModelSuite;
import com.hedera.services.bdd.suites.contract.precompile.CreatePrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.CryptoTransferHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.DefaultTokenStatusSuite;
Expand All @@ -61,7 +62,6 @@
import com.hedera.services.bdd.suites.contract.precompile.TokenInfoHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.TokenUpdatePrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.WipeTokenAccountPrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractMintHTSV2SecurityModelSuite;
import com.hedera.services.bdd.suites.contract.records.LogsSuite;
import com.hedera.services.bdd.suites.contract.records.RecordsSuite;
import com.hedera.services.bdd.suites.crypto.AutoAccountCreationSuite;
Expand Down Expand Up @@ -251,7 +251,8 @@ static Supplier<HapiSuite>[] ethereumSuites() {
// contract.records
RecordsSuite::new,
LogsSuite::new,
Evm46ValidationSuite::new
Evm46ValidationSuite::new,
ContractMintHTSV2SecurityModelSuite::new
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.hedera.services.bdd.junit.TestTags.SMART_CONTRACT;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.HapiSpec.propertyPreservingHapiSpec;
import static com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith;
import static com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith;
import static com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT;
Expand Down Expand Up @@ -129,8 +128,7 @@ final HapiSpec transferNftAfterNestedMint() {
final var nestedTransferTxn = "nestedTransferTxn";
final var v2SecuritySendNftAfterNestedMint = "v2SecuritySendNftAfterNestedMint";

return propertyPreservingHapiSpec("TransferNftAfterNestedMint")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("TransferNftAfterNestedMint")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
newKeyNamed(MULTI_KEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.hedera.services.bdd.suites.contract.precompile;

import static com.hedera.services.bdd.spec.HapiPropertySource.asToken;
import static com.hedera.services.bdd.spec.HapiSpec.propertyPreservingHapiSpec;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith;
import static com.hedera.services.bdd.spec.keys.KeyShape.CONTRACT;
import static com.hedera.services.bdd.spec.keys.KeyShape.ED25519;
Expand Down Expand Up @@ -75,8 +75,6 @@ public class ContractMintHTSV2SecurityModelSuite extends HapiSuite {
private static final KeyShape TRESHOLD_KEY_SHAPE = KeyShape.threshOf(1, ED25519, CONTRACT);
private static final String CONTRACT_KEY = "ContractKey";
public static final String MINT_CONTRACT = "MintContract";
private static final String NESTED_MINT_CONTRACT = "NestedMint";
public static final String MINT_NFT_CONTRACT = "MintNFTContract";
private static final String HTS_CALLS = "HTSCalls";
public static final String TRESHOLD_KEY_CORRECT_CONTRACT_ID =
"tresholdKeyWithCorrectContractAndIncorrectSignerPublicKey";
Expand Down Expand Up @@ -107,7 +105,6 @@ public class ContractMintHTSV2SecurityModelSuite extends HapiSuite {
private static final String TOKEN_HAS_NO_UPDATED_KEY = "tokenHasUpdatedContractKey";
private static final String SIGNER_MINTS_WITH_CONTRACT_ID =
"signerMintsAndTokenSupplyKeyHasTheIntermediaryContractId";
private static final String TOKEN_WITH_CONTRACT_KEY = "tokenHasKeyWithTypeContract";
private static final String SIGNER_MINTS_WITH_THRESHOLD_KEY = "tokenAndSignerHaveThresholdKey";
private static final String SIGNER_MINTS_WITH_SIGNER_PUBLIC_KEY_AND_WRONG_CONTRACT_ID =
"signerMintsAndTokenSupplyKeyHasTheSignerPublicKeyAndTheWrongContractId";
Expand All @@ -124,7 +121,12 @@ public class ContractMintHTSV2SecurityModelSuite extends HapiSuite {
static final byte[][] TEST_METADATA_2 = new byte[][] {TEST_METADATA_1.getBytes()};

public static void main(final String... args) {
new ContractMintHTSV2SecurityModelSuite().runSuiteSync();
new ContractMintHTSV2SecurityModelSuite().runSuiteAsync();
}

@Override
public boolean canRunConcurrent() {
return true;
}

public List<HapiSpec> getSpecsInSuite() {
Expand All @@ -151,8 +153,7 @@ final HapiSpec V2Security002FungibleTokenMintInTreasuryPositive() {
final var amount = 10L;
final AtomicReference<TokenID> fungible = new AtomicReference<>();

return propertyPreservingHapiSpec("V2Security002FungibleTokenMintPositive")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security002FungibleTokenMintPositive")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY),
Expand Down Expand Up @@ -225,6 +226,7 @@ final HapiSpec V2Security002FungibleTokenMintInTreasuryPositive() {
.via(SIGNER_AND_PAYER_ARE_DIFFERENT)
.gas(GAS_TO_OFFER)
.signedBy(SIGNER2, TOKEN_TREASURY)
.refusingEthConversion()
.payingWith(SIGNER2),
// Assert that the token is minted - total supply should be increased
getTokenInfo(FUNGIBLE_TOKEN).hasTotalSupply(3 * amount),
Expand Down Expand Up @@ -277,8 +279,7 @@ final HapiSpec V2Security003NonFungibleTokenMintInTreasuryPositive() {
final var amount = 1;
final AtomicReference<TokenID> nonFungible = new AtomicReference<>();

return propertyPreservingHapiSpec("V2Security003NonFungibleTokenMintPositive")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security003NonFungibleTokenMintPositive")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY),
Expand Down Expand Up @@ -353,7 +354,8 @@ final HapiSpec V2Security003NonFungibleTokenMintInTreasuryPositive() {
.via(SIGNER_AND_PAYER_ARE_DIFFERENT)
.gas(GAS_TO_OFFER)
.signedBy(SIGNER2, TOKEN_TREASURY)
.payingWith(SIGNER2),
.payingWith(SIGNER2)
.refusingEthConversion(),
getTokenInfo(NON_FUNGIBLE_TOKEN).hasTotalSupply(3 * amount),
tokenUpdate(NON_FUNGIBLE_TOKEN).supplyKey(CONTRACT_KEY),
// Assert that the token is minted - total supply should be increased
Expand Down Expand Up @@ -408,8 +410,7 @@ final HapiSpec V2Security002FungibleTokenMintInTreasuryNegative() {
final var amount = 10L;
final AtomicReference<TokenID> fungible = new AtomicReference<>();

return propertyPreservingHapiSpec("V2Security002FungibleTokenMintNegative")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security002FungibleTokenMintNegative")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY),
Expand Down Expand Up @@ -470,7 +471,7 @@ final HapiSpec V2Security002FungibleTokenMintInTreasuryNegative() {
new byte[][] {})
.via(SIGNER_MINTS_WITH_SIGNER_PUBLIC_KEY_AND_WRONG_CONTRACT_ID)
.gas(GAS_TO_OFFER)
.alsoSigningWithFullPrefix(SIGNER)
.signedBy(SIGNER)
.payingWith(SIGNER),
// Assert that the token is NOT minted - total supply should be 0
getTokenInfo(FUNGIBLE_TOKEN).hasTotalSupply(0L),
Expand Down Expand Up @@ -519,8 +520,7 @@ final HapiSpec V2Security002FungibleTokenMintInTreasuryNegative() {
final HapiSpec V2Security003NonFungibleTokenMintInTreasuryNegative() {
final AtomicReference<TokenID> nonFungible = new AtomicReference<>();

return propertyPreservingHapiSpec("V2Security003NonFungibleTokenMintNegative")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security003NonFungibleTokenMintNegative")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY),
Expand Down Expand Up @@ -582,7 +582,7 @@ final HapiSpec V2Security003NonFungibleTokenMintInTreasuryNegative() {
new byte[][] {TEST_METADATA_1.getBytes()})
.via(SIGNER_MINTS_WITH_SIGNER_PUBLIC_KEY_AND_WRONG_CONTRACT_ID)
.gas(GAS_TO_OFFER)
.alsoSigningWithFullPrefix(SIGNER)
.signedBy(SIGNER)
.payingWith(SIGNER),
// Assert that the token is NOT minted - total supply should be 0
getTokenInfo(NON_FUNGIBLE_TOKEN).hasTotalSupply(0L),
Expand Down Expand Up @@ -626,8 +626,7 @@ final HapiSpec V2Security003NonFungibleTokenMintInTreasuryNegative() {

@HapiTest
final HapiSpec V2Security035TokenWithDelegateContractKeyCanNotMintFromDelegatecall() {
return propertyPreservingHapiSpec("V2Security035TokenWithDelegateContractKeyCanNotMintFromDelegatecal")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security035TokenWithDelegateContractKeyCanNotMintFromDelegatecal")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY),
Expand Down Expand Up @@ -771,8 +770,7 @@ final HapiSpec V2Security040TokenWithDelegateContractKeyCanNotMintFromStaticcall
final AtomicReference<TokenID> fungible = new AtomicReference<>();
final AtomicReference<TokenID> nonFungible = new AtomicReference<>();

return propertyPreservingHapiSpec("V2Security040TokenWithDelegateContractKeyCanNotMintFromStaticcall")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security040TokenWithDelegateContractKeyCanNotMintFromStaticcall")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY).balance(ONE_MILLION_HBARS),
Expand Down Expand Up @@ -855,8 +853,7 @@ final HapiSpec V2Security040TokenWithDelegateContractKeyCanNotMintFromCallcode()
final AtomicReference<TokenID> nonFungible = new AtomicReference<>();
final String precompileAddress = "0000000000000000000000000000000000000167";

return propertyPreservingHapiSpec("V2Security040TokenWithDelegateContractKeyCanNotMintFromCallcode")
.preserving(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS)
return defaultHapiSpec("V2Security040TokenWithDelegateContractKeyCanNotMintFromCallcode")
.given(
overriding(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS, CONTRACTS_V2_SECURITY_MODEL_BLOCK_CUTOFF),
cryptoCreate(TOKEN_TREASURY).balance(THOUSAND_HBAR),
Expand Down

0 comments on commit bb0cc01

Please sign in to comment.