use of com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE in project hedera-services by hashgraph.
the class R5BugChecks method enforcesSigRequirements.
private HapiApiSpec enforcesSigRequirements() {
KeyShape complexSrShape = listOf(SIMPLE, threshOf(1, 3));
SigControl activeSig = complexSrShape.signedWith(sigs(ON, sigs(OFF, OFF, ON)));
SigControl inactiveSig = complexSrShape.signedWith(sigs(OFF, sigs(ON, ON, ON)));
return defaultHapiSpec("EnforcesSigRequirements").given(newKeyNamed("srKey").shape(complexSrShape), fileCreate("bytecode").path(ContractResources.LAST_TRACKING_SENDER_BYTECODE_PATH), contractCreate("sponsor").bytecode("bytecode").balance(10), cryptoCreate("noSr").balance(0L), cryptoCreate("sr").key("srKey").balance(0L).receiverSigRequired(true)).when(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).hasKnownStatus(INVALID_SIGNATURE), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", inactiveSig)).hasKnownStatus(INVALID_SIGNATURE), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(0) }))), getAccountBalance("sr").hasTinyBars(0L)).then(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("noSr").getAccountNum(), 1 }), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", activeSig)), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(5) }))), getAccountBalance("sr").hasTinyBars(5L), getAccountBalance("noSr").hasTinyBars(1L));
}
use of com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE 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.SIMPLE 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())));
}
Aggregations