Search in sources :

Example 26 with KeyShape

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

the class GuidedTourRemoteSuite method topLevelHederaKeyMustBeActive.

private HapiApiSpec topLevelHederaKeyMustBeActive() {
    KeyShape waclShape = listOf(SIMPLE, threshOf(2, 3));
    SigControl updateSigControl = waclShape.signedWith(sigs(ON, sigs(ON, OFF, OFF)));
    return customHapiSpec("TopLevelListBehavesAsRevocationService").withProperties(Map.of("host", "34.74.191.8")).given().when().then(fileCreate("target").waclShape(waclShape).sigControl(ControlForKey.forKey("target", updateSigControl)).hasKnownStatus(INVALID_SIGNATURE));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 27 with KeyShape

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

the class createTopicLoadTest method runCreateTopics.

private static HapiApiSpec runCreateTopics() {
    PerfTestLoadSettings settings = new PerfTestLoadSettings();
    final AtomicInteger submittedSoFar = new AtomicInteger(0);
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { createTopic("testTopic" + submittedSoFar.addAndGet(1)).submitKeyShape(submitKeyShape).noLogging().hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
    return defaultHapiSpec("runCreateTopics").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when().then(defaultLoadTest(submitBurst, settings));
}
Also used : LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) 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) List(java.util.List) Logger(org.apache.logging.log4j.Logger) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 28 with KeyShape

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

the class AssortedHcsOps method runMisc.

private HapiApiSpec runMisc() {
    final int SUBMIT_BURST_SIZE = 10;
    AtomicReference<String> vanillaTopic = new AtomicReference<>();
    AtomicReference<String> updatedTopic = new AtomicReference<>();
    AtomicReference<String> deletedTopic = new AtomicReference<>();
    Function<String, HapiSpecOperation[]> submitBurst = ref -> IntStream.range(0, SUBMIT_BURST_SIZE).mapToObj(i -> submitMessageTo(ref).message(String.format("%s message #%d", ref, i))).toArray(n -> new HapiSpecOperation[n]);
    KeyShape origAdminKey = listOf(SIMPLE, threshOf(2, 3), SIMPLE);
    KeyShape origSubmitKey = listOf(SIMPLE, threshOf(2, 3), listOf(5));
    return customHapiSpec("RunMisc").withProperties(Map.of("client.feeSchedule.fromDisk", "false", "client.feeSchedule.path", path("feeSchedule.bin"), "client.exchangeRates.fromDisk", "false", "client.exchangeRates.path", path("exchangeRates.bin"))).given(newKeyNamed("origAdminKey").shape(origAdminKey), newKeyNamed("origSubmitKey").shape(origSubmitKey), createTopic("vanillaTopic").adminKeyName(GENESIS), createTopic("updatedTopic").adminKeyName("origAdminKey").submitKeyName("origSubmitKey"), createTopic("deletedTopic").adminKeyName(GENESIS), withOpContext((spec, opLog) -> {
        vanillaTopic.set(asTopicString(spec.registry().getTopicID("vanillaTopic")));
        updatedTopic.set(asTopicString(spec.registry().getTopicID("updatedTopic")));
        deletedTopic.set(asTopicString(spec.registry().getTopicID("deletedTopic")));
    })).when(flattened(submitBurst.apply("vanillaTopic"), submitBurst.apply("updatedTopic"), submitBurst.apply("deletedTopic"), updateTopic("updatedTopic").adminKey(GENESIS).submitKey(GENESIS), deleteTopic("deletedTopic"))).then(getTopicInfo("vanillaTopic").hasSeqNo(10L), getTopicInfo("updatedTopic").hasSeqNo(10L).hasAdminKey(GENESIS).hasSubmitKey(GENESIS), getTopicInfo("deletedTopic").hasCostAnswerPrecheck(INVALID_TOPIC_ID), logIt(spec -> String.format("Vanilla: %s, Updated: %s, Deleted: %s", vanillaTopic.get(), updatedTopic.get(), deletedTopic.get())));
}
Also used : IntStream(java.util.stream.IntStream) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) INVALID_TOPIC_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOPIC_ID) Path(java.nio.file.Path) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) HapiApiSpec.customHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) QueryVerbs(com.hedera.services.bdd.spec.queries.QueryVerbs) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiPropertySource.asTopicString(com.hedera.services.bdd.spec.HapiPropertySource.asTopicString) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) AtomicReference(java.util.concurrent.atomic.AtomicReference) HapiPropertySource.asTopicString(com.hedera.services.bdd.spec.HapiPropertySource.asTopicString)

Example 29 with KeyShape

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

the class SubmitMessageSuite method messageSubmissionWithSubmitKey.

private HapiApiSpec messageSubmissionWithSubmitKey() {
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    SigControl validSig = submitKeyShape.signedWith(sigs(ON, OFF, sigs(ON, ON)));
    SigControl invalidSig = submitKeyShape.signedWith(sigs(ON, OFF, sigs(ON, OFF)));
    return defaultHapiSpec("messageSubmissionWithSubmitKey").given(newKeyNamed("submitKey").shape(submitKeyShape), createTopic("testTopic").submitKeyName("submitKey")).when().then(submitMessageTo("testTopic").sigControl(forKey("testTopicSubmit", invalidSig)).hasRetryPrecheckFrom(BUSY).hasKnownStatus(INVALID_SIGNATURE), submitMessageTo("testTopic").sigControl(forKey("testTopicSubmit", validSig)).hasRetryPrecheckFrom(BUSY).hasKnownStatus(SUCCESS));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 30 with KeyShape

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

the class ValidationScenarios method novelFileIfDesired.

private static HapiSpecOperation[] novelFileIfDesired() {
    if (!params.isNovelContent()) {
        return new HapiSpecOperation[0];
    }
    KeyShape firstComplex = KeyShape.listOf(KeyShape.threshOf(2, 3), KeyShape.threshOf(1, 3));
    KeyShape secondComplex = KeyShape.listOf(3);
    SigControl normalDelete = secondComplex.signedWith(KeyShape.sigs(ON, ON, ON));
    SigControl revocation = secondComplex.signedWith(KeyShape.sigs(ON, OFF, OFF));
    return new HapiSpecOperation[] { newKeyNamed("novelFileFirstKey").shape(firstComplex), newKeyNamed("novelFileSecondKey").shape(secondComplex), fileCreate(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).key("novelFileFirstKey").contents("abcdefghijklm"), fileAppend(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).content("nopqrstuvwxyz"), getFileContents(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).hasContents(ignore -> "abcdefghijklmnopqrstuvwxyz".getBytes()), fileUpdate(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).wacl("novelFileSecondKey"), fileDelete(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).sigControl(ControlForKey.forKey(NOVEL_FILE_NAME, params.isRevocationService() ? revocation : normalDelete)), withOpContext((spec, opLog) -> novelFileUsed.set(HapiPropertySource.asFileString(spec.registry().getFileId(NOVEL_FILE_NAME)))) };
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

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