Search in sources :

Example 11 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class Issue2150Spec method multiKeyNonPayerEntityVerifiedAsync.

private HapiApiSpec multiKeyNonPayerEntityVerifiedAsync() {
    KeyShape LARGE_THRESH_SHAPE = KeyShape.threshOf(1, 10);
    SigControl firstOnly = LARGE_THRESH_SHAPE.signedWith(sigs(ON, OFF, OFF, OFF, OFF, OFF, OFF, OFF, OFF, OFF));
    return defaultHapiSpec("MultiKeyNonPayerEntityVerifiedAsync").given(newKeyNamed("payerKey").shape(LARGE_THRESH_SHAPE), newKeyNamed("receiverKey").shape(LARGE_THRESH_SHAPE), cryptoCreate("payer").keyShape(LARGE_THRESH_SHAPE), cryptoCreate("receiver").keyShape(LARGE_THRESH_SHAPE).receiverSigRequired(true)).when().then(cryptoTransfer(tinyBarsFromTo("payer", "receiver", 1L)).sigControl(forKey("payer", firstOnly), forKey("receiver", firstOnly)));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 12 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class ContractCreateSuite method createFailsIfMissingSigs.

private HapiApiSpec createFailsIfMissingSigs() {
    KeyShape shape = listOf(SIMPLE, threshOf(2, 3), threshOf(1, 3));
    SigControl validSig = shape.signedWith(sigs(ON, sigs(ON, ON, OFF), sigs(OFF, OFF, ON)));
    SigControl invalidSig = shape.signedWith(sigs(OFF, sigs(ON, ON, OFF), sigs(OFF, OFF, ON)));
    return defaultHapiSpec("CreateFailsIfMissingSigs").given(fileCreate("contractFile").path(ContractResources.VALID_BYTECODE_PATH)).when().then(contractCreate("testContract").adminKeyShape(shape).bytecode("contractFile").sigControl(forKey("testContract", invalidSig)).hasKnownStatus(INVALID_SIGNATURE), contractCreate("testContract").adminKeyShape(shape).bytecode("contractFile").sigControl(forKey("testContract", validSig)));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 13 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class ScheduleCreateSpecs method preservesRevocationServiceSemanticsForFileDelete.

private HapiApiSpec preservesRevocationServiceSemanticsForFileDelete() {
    KeyShape waclShape = listOf(SIMPLE, threshOf(2, 3));
    SigControl adequateSigs = waclShape.signedWith(sigs(OFF, sigs(ON, ON, OFF)));
    SigControl inadequateSigs = waclShape.signedWith(sigs(OFF, sigs(ON, OFF, OFF)));
    SigControl compensatorySigs = waclShape.signedWith(sigs(OFF, sigs(OFF, OFF, ON)));
    String shouldBeInstaDeleted = "tbd";
    String shouldBeDeletedEventually = "tbdl";
    return defaultHapiSpec("PreservesRevocationServiceSemanticsForFileDelete").given(overriding("scheduling.whitelist", "FileDelete"), fileCreate(shouldBeInstaDeleted).waclShape(waclShape), fileCreate(shouldBeDeletedEventually).waclShape(waclShape)).when(scheduleCreate("validRevocation", fileDelete(shouldBeInstaDeleted)).alsoSigningWith(shouldBeInstaDeleted).sigControl(forKey(shouldBeInstaDeleted, adequateSigs)), sleepFor(1_000L), getFileInfo(shouldBeInstaDeleted).hasDeleted(true)).then(scheduleCreate("notYetValidRevocation", fileDelete(shouldBeDeletedEventually)).alsoSigningWith(shouldBeDeletedEventually).sigControl(forKey(shouldBeDeletedEventually, inadequateSigs)), getFileInfo(shouldBeDeletedEventually).hasDeleted(false), scheduleSign("notYetValidRevocation").alsoSigningWith(shouldBeDeletedEventually).sigControl(forKey(shouldBeDeletedEventually, compensatorySigs)), sleepFor(1_000L), getFileInfo(shouldBeDeletedEventually).hasDeleted(true), overriding("scheduling.whitelist", defaultWhitelist));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 14 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class CreateTopicPerfSuite method createTopicPerf.

private HapiApiSpec createTopicPerf() {
    final int NUM_TOPICS = 100000;
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    return defaultHapiSpec("createTopicPerf").given().when(startThroughputObs("createTopicThroughput").msToSaturateQueues(50L), inParallel(// only ask for record for the last transaction
    asOpArray(NUM_TOPICS, i -> (i == (NUM_TOPICS - 1)) ? createTopic("testTopic" + i).submitKeyShape(submitKeyShape) : createTopic("testTopic" + i).submitKeyShape(submitKeyShape).deferStatusResolution()))).then(// wait until the record of the last transaction are ready
    finishThroughputObs("createTopicThroughput").gatedByQuery(() -> getTopicInfo("testTopic" + (NUM_TOPICS - 1))).sleepMs(1_000L).expiryMs(300_000L));
}
Also used : Arrays(java.util.Arrays) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) UtilVerbs.startThroughputObs(com.hedera.services.bdd.spec.utilops.UtilVerbs.startThroughputObs) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) UtilVerbs.finishThroughputObs(com.hedera.services.bdd.spec.utilops.UtilVerbs.finishThroughputObs) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 15 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class ContractUpdateSuite method fridayThe13thSpec.

HapiApiSpec fridayThe13thSpec() {
    long newExpiry = Instant.now().getEpochSecond() + DEFAULT_PROPS.defaultExpirationSecs() * 2;
    long betterExpiry = Instant.now().getEpochSecond() + DEFAULT_PROPS.defaultExpirationSecs() * 3;
    final String INITIAL_MEMO = "This is a memo string with only Ascii characters";
    final String NEW_MEMO = "Turning and turning in the widening gyre, the falcon cannot hear the falconer...";
    final String BETTER_MEMO = "This was Mr. Bleaney's room...";
    KeyShape initialKeyShape = KeyShape.SIMPLE;
    KeyShape newKeyShape = listOf(3);
    return defaultHapiSpec("FridayThe13thSpec").given(newKeyNamed("initialAdminKey").shape(initialKeyShape), newKeyNamed("newAdminKey").shape(newKeyShape), cryptoCreate("payer").balance(10 * ONE_HUNDRED_HBARS), fileCreate("bytecode").path(ContractResources.SIMPLE_STORAGE_BYTECODE_PATH).payingWith("payer")).when(contractCreate("immutableContract").payingWith("payer").omitAdminKey().bytecode("bytecode"), contractCreate("contract").payingWith("payer").adminKey("initialAdminKey").entityMemo(INITIAL_MEMO).bytecode("bytecode"), getContractInfo("contract").payingWith("payer").logged().has(contractWith().memo(INITIAL_MEMO).adminKey("initialAdminKey"))).then(contractUpdate("contract").payingWith("payer").newKey("newAdminKey").signedBy("payer", "initialAdminKey").hasKnownStatus(INVALID_SIGNATURE), contractUpdate("contract").payingWith("payer").newKey("newAdminKey").signedBy("payer", "newAdminKey").hasKnownStatus(INVALID_SIGNATURE), contractUpdate("contract").payingWith("payer").newKey("newAdminKey"), contractUpdate("contract").payingWith("payer").newExpirySecs(newExpiry).newMemo(NEW_MEMO), getContractInfo("contract").payingWith("payer").logged().has(contractWith().solidityAddress("contract").memo(NEW_MEMO).expiry(newExpiry)), contractUpdate("contract").payingWith("payer").newMemo(BETTER_MEMO), getContractInfo("contract").payingWith("payer").logged().has(contractWith().memo(BETTER_MEMO).expiry(newExpiry)), contractUpdate("contract").payingWith("payer").newExpirySecs(betterExpiry), getContractInfo("contract").payingWith("payer").logged().has(contractWith().memo(BETTER_MEMO).expiry(betterExpiry)), contractUpdate("contract").payingWith("payer").signedBy("payer").newExpirySecs(newExpiry).hasKnownStatus(EXPIRATION_REDUCTION_NOT_ALLOWED), contractUpdate("contract").payingWith("payer").signedBy("payer").newMemo(NEW_MEMO).hasKnownStatus(INVALID_SIGNATURE), contractUpdate("contract").payingWith("payer").signedBy("payer", "initialAdminKey").hasKnownStatus(INVALID_SIGNATURE), contractUpdate("immutableContract").payingWith("payer").newMemo(BETTER_MEMO).hasKnownStatus(MODIFYING_IMMUTABLE_CONTRACT), contractDelete("immutableContract").payingWith("payer").hasKnownStatus(MODIFYING_IMMUTABLE_CONTRACT), contractUpdate("immutableContract").payingWith("payer").newExpirySecs(betterExpiry), contractDelete("contract").payingWith("payer").signedBy("payer", "initialAdminKey").hasKnownStatus(INVALID_SIGNATURE), contractDelete("contract").payingWith("payer").signedBy("payer").hasKnownStatus(INVALID_SIGNATURE), contractDelete("contract").payingWith("payer").hasKnownStatus(SUCCESS));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Aggregations

KeyShape (com.hedera.services.bdd.spec.keys.KeyShape)30 SigControl (com.hedera.services.bdd.spec.keys.SigControl)11 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)9 KeyShape.listOf (com.hedera.services.bdd.spec.keys.KeyShape.listOf)9 List (java.util.List)9 LogManager (org.apache.logging.log4j.LogManager)9 Logger (org.apache.logging.log4j.Logger)9 SIMPLE (com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE)8 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)8 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)8 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)7 KeyShape.threshOf (com.hedera.services.bdd.spec.keys.KeyShape.threshOf)6 UtilVerbs.newKeyNamed (com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed)6 Map (java.util.Map)6 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)5 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)5 TxnVerbs.fileUpdate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate)5 HapiApiSpec.customHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec)4 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)4 QueryVerbs.getFileInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo)4