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));
}
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));
}
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())));
}
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));
}
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)))) };
}
Aggregations